public void Start(string[] startupArguments, ServiceStoppedCallback serviceStoppedCallback) { Logger.Log(LogLevel.Info, "Service Starting."); string url = null; string dynamoDbConfigJson = null; var builder = new ConfigurationBuilder(); builder.AddCommandLine(startupArguments); if (!this.StartupConfig.IsTest) { // No need to spend time checking dynamo db if in test mode dynamoDbConfigJson = DynamoDbConfigurationProviderFactory.Create().GetJson(); if (!string.IsNullOrWhiteSpace(dynamoDbConfigJson)) { var dynamoAppSettingsFileName = "appsettings.dynamodb.json"; var provider = new InMemoryFileProvider(); provider.Directory.AddFile("/", new StringFileInfo(dynamoDbConfigJson, dynamoAppSettingsFileName)); provider.EnsureFile($"/{dynamoAppSettingsFileName}"); builder.AddJsonFile(provider, $"/{dynamoAppSettingsFileName}", false, false); } } var config = builder.Build(); url = config.GetValue <string>("SurveillanceApiUrl"); if (string.IsNullOrWhiteSpace(url)) { url = "https://localhost:8888"; } this._webHost = CreateWebHostBuilder(startupArguments, dynamoDbConfigJson, url, this.StartupConfig).Build(); // Make sure the windows service is stopped if the // ASP.NET Core stack stops for any reason this._webHost.Services.GetRequiredService <IHostApplicationLifetime>().ApplicationStopped.Register( () => { if (this._stopRequestedByWindows == false) { serviceStoppedCallback(); } }); Logger.Log(LogLevel.Info, "WebHost Starting."); this._webHost.Start(); Logger.Log(LogLevel.Info, "WebHost Started."); Logger.Log(LogLevel.Info, "Service Started."); }