private async Task <IWebHost> BuildWebHost(ScriptApplicationHostOptions hostOptions, WorkerRuntime workerRuntime, Uri baseAddress, X509Certificate2 certificate) { IDictionary <string, string> settings = await GetConfigurationSettings(hostOptions.ScriptPath, baseAddress); settings.AddRange(LanguageWorkerHelper.GetWorkerConfiguration(workerRuntime, LanguageWorkerSetting)); UpdateEnvironmentVariables(settings); var defaultBuilder = Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(Array.Empty <string>()); if (UseHttps) { defaultBuilder .UseKestrel(options => { options.Listen(IPAddress.Loopback, baseAddress.Port, listenOptins => { listenOptins.UseHttps(certificate); }); }); } return(defaultBuilder .UseSetting(WebHostDefaults.ApplicationKey, typeof(Startup).Assembly.GetName().Name) .UseUrls(baseAddress.ToString()) .ConfigureAppConfiguration(configBuilder => { configBuilder.AddEnvironmentVariables(); }) .ConfigureServices((context, services) => services.AddSingleton <IStartup>(new Startup(context, hostOptions, CorsOrigins))) .Build()); }
private async Task <IWebHost> BuildWebHost(ScriptApplicationHostOptions hostOptions, Uri listenAddress, Uri baseAddress, X509Certificate2 certificate) { IDictionary <string, string> settings = await GetConfigurationSettings(hostOptions.ScriptPath, baseAddress); settings.AddRange(LanguageWorkerHelper.GetWorkerConfiguration(LanguageWorkerSetting)); UpdateEnvironmentVariables(settings); LoggingFilterHelper loggingFilterHelper = new LoggingFilterHelper(_hostJsonConfig, VerboseLogging); var defaultBuilder = Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(Array.Empty <string>()); if (UseHttps) { defaultBuilder .UseKestrel(options => { options.Listen(IPAddress.Any, listenAddress.Port, listenOptins => { listenOptins.UseHttps(certificate); }); }); } return(defaultBuilder .UseSetting(WebHostDefaults.ApplicationKey, typeof(Startup).Assembly.GetName().Name) .UseUrls(listenAddress.ToString()) .ConfigureAppConfiguration(configBuilder => { configBuilder.AddEnvironmentVariables(); }) .ConfigureLogging(loggingBuilder => { loggingBuilder.ClearProviders(); loggingBuilder.Services.AddSingleton <ILoggerProvider>(p => { //Cache LoggerFilterOptions to be used by the logger to filter logs based on content var filterOptions = p.GetService <IOptions <LoggerFilterOptions> >().Value; // Set min level to SystemLogDefaultLogLevel. filterOptions.MinLevel = loggingFilterHelper.SystemLogDefaultLogLevel; return new ColoredConsoleLoggerProvider(loggingFilterHelper, filterOptions); }); // This is needed to filter system logs only for known categories loggingBuilder.AddDefaultWebJobsFilters <ColoredConsoleLoggerProvider>(LogLevel.Trace); }) .ConfigureServices((context, services) => services.AddSingleton <IStartup>(new Startup(context, hostOptions, CorsOrigins, CorsCredentials, EnableAuth, loggingFilterHelper))) .Build()); }
private async Task <IWebHost> BuildWebHost(ScriptApplicationHostOptions hostOptions, Uri listenAddress, Uri baseAddress, X509Certificate2 certificate) { IDictionary <string, string> settings = await GetConfigurationSettings(hostOptions.ScriptPath, baseAddress); settings.AddRange(LanguageWorkerHelper.GetWorkerConfiguration(LanguageWorkerSetting)); UpdateEnvironmentVariables(settings); var defaultBuilder = Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(Array.Empty <string>()); if (UseHttps) { defaultBuilder .UseKestrel(options => { options.Listen(IPAddress.Loopback, listenAddress.Port, listenOptins => { listenOptins.UseHttps(certificate); }); }); } return(defaultBuilder .UseSetting(WebHostDefaults.ApplicationKey, typeof(Startup).Assembly.GetName().Name) .UseUrls(listenAddress.ToString()) .ConfigureAppConfiguration(configBuilder => { configBuilder.AddEnvironmentVariables(); }) .ConfigureLogging(loggingBuilder => { loggingBuilder.ClearProviders(); loggingBuilder.AddDefaultWebJobsFilters(); loggingBuilder.AddProvider(new ColoredConsoleLoggerProvider((cat, level) => level >= LogLevel.Information)); }) .ConfigureServices((context, services) => services.AddSingleton <IStartup>(new Startup(context, hostOptions, CorsOrigins, CorsCredentials, EnableAuth))) .Build()); }