[Azure] Move to GenericHost (#24283)
This commit is contained in:
parent
e23f83d557
commit
9a4eb51595
|
|
@ -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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace AzureADB2CSample
|
namespace AzureADB2CSample
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static Task Main(string[] args)
|
||||||
{
|
{
|
||||||
CreateWebHostBuilder(args).Build().Run();
|
var host = new HostBuilder()
|
||||||
}
|
.ConfigureWebHost(webHostBuilder =>
|
||||||
|
{
|
||||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
webHostBuilder
|
||||||
new WebHostBuilder()
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
.UseIISIntegration()
|
||||||
.ConfigureAppConfiguration((hostingContext, config) =>{
|
.UseKestrel()
|
||||||
|
.UseStartup<Startup>();
|
||||||
|
})
|
||||||
|
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||||
|
{
|
||||||
var env = hostingContext.HostingEnvironment;
|
var env = hostingContext.HostingEnvironment;
|
||||||
|
|
||||||
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||||
|
|
@ -32,8 +38,9 @@ namespace AzureADB2CSample
|
||||||
.AddConsole()
|
.AddConsole()
|
||||||
.AddDebug();
|
.AddDebug();
|
||||||
})
|
})
|
||||||
.UseIISIntegration()
|
.Build();
|
||||||
.UseKestrel()
|
|
||||||
.UseStartup<Startup>();
|
return host.RunAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,29 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace AzureADSample
|
namespace AzureADSample
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static Task Main(string[] args)
|
||||||
{
|
{
|
||||||
CreateWebHostBuilder(args).Build().Run();
|
var host = new HostBuilder()
|
||||||
}
|
.ConfigureWebHost(webHostBuilder =>
|
||||||
|
{
|
||||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
webHostBuilder
|
||||||
new WebHostBuilder()
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
.UseIISIntegration()
|
||||||
.ConfigureAppConfiguration((hostingContext, config) =>{
|
.UseKestrel()
|
||||||
|
.UseStartup<Startup>();
|
||||||
|
})
|
||||||
|
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||||
|
{
|
||||||
var env = hostingContext.HostingEnvironment;
|
var env = hostingContext.HostingEnvironment;
|
||||||
|
|
||||||
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||||
|
|
@ -32,8 +38,9 @@ namespace AzureADSample
|
||||||
.AddConsole()
|
.AddConsole()
|
||||||
.AddDebug();
|
.AddDebug();
|
||||||
})
|
})
|
||||||
.UseIISIntegration()
|
.Build();
|
||||||
.UseKestrel()
|
|
||||||
.UseStartup<Startup>();
|
return host.RunAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace IISSample
|
namespace IISSample
|
||||||
|
|
@ -58,18 +60,22 @@ namespace IISSample
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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 =>
|
.ConfigureLogging(factory =>
|
||||||
{
|
{
|
||||||
factory.AddConsole();
|
factory.AddConsole();
|
||||||
})
|
})
|
||||||
.UseKestrel()
|
|
||||||
.UseStartup<Startup>()
|
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
host.Run();
|
return host.RunAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace IISSample
|
namespace IISSample
|
||||||
|
|
@ -70,20 +72,23 @@ namespace IISSample
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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 =>
|
.ConfigureLogging(factory =>
|
||||||
{
|
{
|
||||||
factory.AddConsole();
|
factory.AddConsole();
|
||||||
})
|
})
|
||||||
.UseKestrel()
|
|
||||||
.UseAzureAppServices()
|
|
||||||
.UseStartup<Startup>()
|
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
host.Run();
|
return host.RunAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue