I am having a slight (though, not impacting functionality) issue with Azure App Service and the ASPNETCORE_ENVIRONMENT. On my local development environment I used the command setx ASPNETCORE_ENVIRONMENT "Development" to set my local to Development. When I output the value of Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") in my local it correctly returns "Development" and correctly selects the proper Development appSettings JSON file. So far so good.
Here is where things get weird (or maybe it's correct?). In Azure App Service I set the ASPNETCORE_ENVIRONMENT value within the Application Settings portion to "Production". When I output this value in the application it says "Production;Development". I was expecting "Production". The application is correctly pulling the production appSetting values, but why am I seeing both values? I was able to adapt my code to check if the value .Contains("Production") for production specific functionality, but I cannot figure out why both values are present. I have researched thoroughly and cannot find a reason. My solution and project files have no variables set. My Azure Build/Pipline has no variables set for this.
Any thoughts?
This ended up being caused by a process adding a "Web.config" file and pre-populating it with ASPNETCORE_ENVIRONMENT. Removing the value from the Web.config worked. I have since then been only setting environment values on the machines/systems/cloud apps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With