Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure App Service - ASPNETCORE_ENVIRONMENT - Multiple Values Issue

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?

like image 621
0xElGato Avatar asked Dec 24 '22 01:12

0xElGato


1 Answers

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.

like image 89
0xElGato Avatar answered Jan 05 '23 19:01

0xElGato