public void Configure(ILoggingBuilder builder) { _loggingFilterHelper.AddConsoleLoggingProvider(builder); builder.Services.AddSingleton <TelemetryClient>(provider => { TelemetryConfiguration configuration = provider.GetService <TelemetryConfiguration>(); TelemetryClient client = new TelemetryClient(configuration); client.Context.GetInternalContext().SdkVersion = $"azurefunctionscoretools: {Constants.CliVersion}"; return(client); }); }
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(); loggingFilterHelper.AddConsoleLoggingProvider(loggingBuilder); }) .ConfigureServices((context, services) => services.AddSingleton <IStartup>(new Startup(context, hostOptions, CorsOrigins, CorsCredentials, EnableAuth, loggingFilterHelper))) .Build()); }