Azure上的ASP.NET Core 6应用程序默认使用开发环境?

发布于 2025-01-24 01:49:12 字数 438 浏览 0 评论 0原文

我正在使用ASP.NET Core 6。在我的本地计算机上,它正确使用了我的开发应用程序设置(appSettings.development.json>),感谢abougned> abination> >。

当我在Linux服务器上发布它时,它正确使用了我的生产应用程序设置(AppSettings.json)。

但是,当我将其上传到Azure时,它默认使用了开发环境,而我毫无意义。我什至在Azure中添加了Aspnetcore_environment设置为production,但被忽略了。我唯一的解决方法是从服务器中删除appSettings.development.json文件...

有什么想法会导致这件事?

I'm using ASP.NET Core 6. On my local machine, it correctly uses my development app settings (the ones from appsettings.Development.json) thanks to launchSettings.json.

When I publish it on a linux server, it correctly uses my production app settings (the ones from appsettings.json).

But when I upload it to Azure, it uses by default the development environment and I am clueless why. I even added ASPNETCORE_ENVIRONMENT set to Production in Azure, but it is ignored. My only workaround is to remove the appsettings.Development.json file from the server...

Any idea what could be causing that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沙沙粒小 2025-01-31 01:49:12

通过在解决方案中搜索Aspnetcore_environment,我发现它设置为Web.config文件中的开发。我记得我尝试在IIS下本地运行该应用程序,但不记得我设置了该变量。我想它当时创建了文件。

因此,如果您处于同一情况,请考虑可能影响Azure出版物的Web.config文件。

更新:我进行了测试。我创建了IIS启动配置。 VS创建了Web.config文件。然后,我在UI中手动添加了Aspnetcore_environment。它将其添加到Web.config文件中。然后,在UI中,我删除了Env var。猜怎么着?它没有将其从文件中删除...

By searching ASPNETCORE_ENVIRONMENT in the solution, I found it to be set to Development in a web.config file. I remember that I tried to run the app locally under IIS but can't remember that I set the variable. I guess it created the file at that time.

So if you are in the same situation, think about the web.config file which could affect the publication to Azure.

Update: I made the test. I created an IIS launch config. VS created the web.config file. Then I manually added ASPNETCORE_ENVIRONMENT in the UI. It added it to the web.config file. In the UI, I then removed the env var. Guess what? It didn't remove it from the file...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文