Skip to content

[Azure] Move to GenericHost #24283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions src/Azure/AzureAD/samples/AzureADB2CSample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace AzureADB2CSample
{
public class Program
{
public static void Main(string[] args)
public static Task Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>{
var host = new HostBuilder()
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseKestrel()
.UseStartup<Startup>();
})
.ConfigureAppConfiguration((hostingContext, config) =>
{
var env = hostingContext.HostingEnvironment;

config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
Expand All @@ -32,8 +38,9 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
.AddConsole()
.AddDebug();
})
.UseIISIntegration()
.UseKestrel()
.UseStartup<Startup>();
.Build();

return host.RunAsync();
}
}
}
29 changes: 18 additions & 11 deletions src/Azure/AzureAD/samples/AzureADSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace AzureADSample
{
public class Program
{
public static void Main(string[] args)
public static Task Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>{
var host = new HostBuilder()
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseKestrel()
.UseStartup<Startup>();
})
.ConfigureAppConfiguration((hostingContext, config) =>
{
var env = hostingContext.HostingEnvironment;

config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
Expand All @@ -32,8 +38,9 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
.AddConsole()
.AddDebug();
})
.UseIISIntegration()
.UseKestrel()
.UseStartup<Startup>();
.Build();

return host.RunAsync();
}
}
}
16 changes: 11 additions & 5 deletions src/Azure/samples/AzureAppServicesHostingStartupSample/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace IISSample
Expand Down Expand Up @@ -58,18 +60,22 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
});
}

public static void Main(string[] args)
public static Task Main(string[] args)
{
var host = new WebHostBuilder()
var host = new HostBuilder()
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseKestrel()
.UseStartup<Startup>();
})
.ConfigureLogging(factory =>
{
factory.AddConsole();
})
.UseKestrel()
.UseStartup<Startup>()
.Build();

host.Run();
return host.RunAsync();
}
}
}
Expand Down
19 changes: 12 additions & 7 deletions src/Azure/samples/AzureAppServicesSample/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace IISSample
Expand Down Expand Up @@ -70,20 +72,23 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
});
}

public static void Main(string[] args)
public static Task Main(string[] args)
{
var host = new WebHostBuilder()
var host = new HostBuilder()
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder
.UseKestrel()
.UseAzureAppServices()
.UseStartup<Startup>();
})
.ConfigureLogging(factory =>
{
factory.AddConsole();
})
.UseKestrel()
.UseAzureAppServices()
.UseStartup<Startup>()
.Build();

host.Run();
return host.RunAsync();
}
}
}