VSO CI - ASPNETCORE_ENVIRONMENT is set to Producti

2019-07-24 16:40发布

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 environment: enter image description here enter image description here

setting it on release configuration: enter image description here

And I'm also ruining the command setx with parameter ASPNETCORE_ENVIRONMENT "Test".

setx command

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.

1条回答
ら.Afraid
2楼-- · 2019-07-24 17:23

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

查看更多
登录 后发表回答