I have an API hosted in IIS.
In local testing, with very scenario, it works perfectly. When deployed to IIS, the appsettings.uat1.json did not get loaded and some environment variables are not changed.
var environment = builder.Configuration.GetSection("Environment").Get<string>();
_logger.Info($"Environment set to: {environment}");
builder.Configuration.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
.AddEnvironmentVariables();
_logger.Info($"Client group environment set to: {builder.Configuration.GetSection("Client:GroupEnviroment").Get<string>()}");
In the log file from IIS I can see the following:
Environment set to: uat1
Client group environment set to: dev6
Now the dev6 value is coming from appsettings.json and the uat1 is coming from appsettings.uat1.json.
I can't figure it out why is that in local testing, I can see that the appsettings.uat1.json is loaded, and the configuration has the right value, but when deployed to IIS, the appsettings.env.json is not loaded, the values for the key are not replaced with redefined in the env json file.
Thanks