VSO CI-无论我做什么,ASPNETCORE_ENVIRONMENT都设置为“生产" [英] VSO CI - ASPNETCORE_ENVIRONMENT is set to Production no matter what I do
问题描述
我正在VSO中创建我的CI管道,并且我具有.net核心应用程序,我创建了一个端点,该端点告诉我在发布过程中使用了哪个值,并通过API公开了IHostingEnvironment.EnvironmentName
,无论我做什么,都已设置到Produciton
.我的应用程序托管在Azure中.
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.
我所做的步骤-
我研究了Azure App Service的应用程序设置,寻找环境.认为这可能会覆盖Release配置中的变量.
I looked into Azure App Service 's application settings, looking for environment. Thinking that might overwrite my variable in Release configuration.
我在发行版配置中的变量选项卡上设置了ASPNETCORE_ENVIRONMENT
变量,也将其设置在特定的环境中.
I set ASPNETCORE_ENVIRONMENT
variable on variables tab in release configuration, also I set it on specific environment.
将其设置为环境:
setting it on environment:
在发布配置中进行设置:
setting it on release configuration:
而且我还破坏了带有参数ASPNETCORE_ENVIRONMENT "Test"
的命令setx
.
And I'm also ruining the command setx
with parameter ASPNETCORE_ENVIRONMENT "Test"
.
以上所有内容似乎都没有什么不同,当我查询端点时,我回到了Production
环境.任何帮助深表感谢.
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.
推荐答案
关于build或release的变量,它只影响build服务器.您需要在Azure中为Web应用设置环境变量,而不是在构建服务器中.
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.
您可以在azure门户中配置环境变量:选择应用程序服务>应用程序设置>将ASPNETCORE_ENVIRONMENT密钥添加到应用程序设置并设置一个值(例如,开发)
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
这篇关于VSO CI-无论我做什么,ASPNETCORE_ENVIRONMENT都设置为“生产"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!