I would like to use App settings for Production environment, as defined in the Azure Web App: See here
Currently using appsettings*.json
files to get these values in Program.cs
for the correct environment:
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((builderContext, config) =>
{
IHostingEnvironment env = builderContext.HostingEnvironment;
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
})
.UseStartup<Startup>()
.Build();
These values are currently defined in the json e.g.
"ConnectionStrings": {
"LocalizationAdminContext": "Data Source=example;Initial Catalog=example;Integrated Security=True;MultipleActiveResultSets=True"
},
"DbResourceConfiguration": {
"ConnectionString": "Data Source=example;Initial Catalog=example;Integrated Security=True;MultipleActiveResultSets=True"
}
I tried to remove these from the appsettings.production.json
to force it to use the ones supplied in Azure, but it errored. I would think that as it's set up in Program.cs
it will always search for the settings in the relevant environment json file.
How do I overwrite this in config to use the application settings? Preferably for Production environment only.