I'm creating my CI pipeline in VSO and I have .net core app, I created endpoint which says to me which value was used during publishing, exposing IHostingEnvironment.EnvironmentName
through the API, no matter what I do, it's set to Produciton
. My app is hosted in Azure.
The steps I did -
I looked into Azure App Service 's application settings, looking for environment. Thinking that might overwrite my variable in Release configuration.
I set ASPNETCORE_ENVIRONMENT
variable on variables tab in release configuration, also I set it on specific environment.
setting it on release configuration:
And I'm also ruining the command setx
with parameter ASPNETCORE_ENVIRONMENT "Test"
.
None of the above seems to make any difference, when I query my endpoint I got back I'm running on Production
environment. Any help is much appreciated.
Regarding variable of build or release, it just affect build server. You need set environment variable for web app in azure instead in build server.
You can configure environment variable in azure portal: Select your App Service> Application Settings> Add ASPNETCORE_ENVIRONMENT key to App Settings and set a value (e.g. Development)
On the other hand, there is a thread about update app settings programing that may benefit you: Change Azure website app settings from code