in src/WebJobs.Script.WebHost/Program.cs [39:100]
public static IWebHostBuilder CreateWebHostBuilder(string[] args = null)
{
// Setting this env variable to test placeholder scenarios locally.
#if PLACEHOLDER_SIMULATION
SystemEnvironment.Instance.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsitePlaceholderMode, "1");
SystemEnvironment.Instance.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteContainerReady, "0");
#endif
return AspNetCore.WebHost.CreateDefaultBuilder(args)
.ConfigureKestrel(o =>
{
o.Limits.MaxRequestBodySize = ScriptConstants.DefaultMaxRequestBodySize;
})
.UseSetting(WebHostDefaults.EnvironmentKey, Environment.GetEnvironmentVariable(EnvironmentSettingNames.EnvironmentNameKey))
.ConfigureServices(services =>
{
services.Configure<IISServerOptions>(o =>
{
o.MaxRequestBodySize = ScriptConstants.DefaultMaxRequestBodySize;
});
})
.ConfigureAppConfiguration((builderContext, config) =>
{
// replace the default environment source with our own
IConfigurationSource envVarsSource = config.Sources.OfType<EnvironmentVariablesConfigurationSource>().FirstOrDefault();
if (envVarsSource != null)
{
config.Sources.Remove(envVarsSource);
}
config.Add(new ScriptEnvironmentVariablesConfigurationSource());
config.Add(new WebScriptHostConfigurationSource
{
IsAppServiceEnvironment = SystemEnvironment.Instance.IsAppService(),
IsLinuxContainerEnvironment = SystemEnvironment.Instance.IsAnyLinuxConsumption(),
IsLinuxAppServiceEnvironment = SystemEnvironment.Instance.IsLinuxAppService()
});
config.Add(new FunctionsHostingConfigSource(SystemEnvironment.Instance));
var hostingEnvironmentConfigFilePath = SystemEnvironment.Instance.GetFunctionsHostingEnvironmentConfigFilePath();
if (!string.IsNullOrEmpty(hostingEnvironmentConfigFilePath))
{
config.AddJsonFile(hostingEnvironmentConfigFilePath, optional: true, reloadOnChange: false);
}
})
.ConfigureLogging((context, loggingBuilder) =>
{
loggingBuilder.ClearProviders();
loggingBuilder.AddDefaultWebJobsFilters();
loggingBuilder.AddWebJobsSystem<WebHostSystemLoggerProvider>();
loggingBuilder.Services.AddSingleton<DeferredLoggerProvider>();
loggingBuilder.Services.AddSingleton<ILoggerProvider>(s => s.GetRequiredService<DeferredLoggerProvider>());
loggingBuilder.Services.AddSingleton<ISystemLoggerFactory, SystemLoggerFactory>();
if (context.HostingEnvironment.IsDevelopment())
{
loggingBuilder.AddConsole();
}
})
.UseStartup<Startup>();
}