如何为虚拟路径中部署的应用程序覆盖 Azure 应用服务中的 appsettings.json 值

问题描述 投票:0回答:1

我有一个 .NET 8 应用程序作为虚拟应用程序以及根文件夹中的另一个应用程序部署到 Azure 应用程序服务。

我能够覆盖根应用程序的应用程序设置,但无法覆盖虚拟应用程序。

我找不到与此相关的任何文档。

azure asp.net-core azure-appservice asp.net-core-8
1个回答
0
投票

我能够覆盖根应用程序和虚拟应用程序的应用程序设置。

虚拟路径:

enter image description here

  • 我没有对代码进行任何更改。

环境变量:

enter image description here

  • 尝试检索
    .cshtml
    文件中的设置。

根应用程序:

@inject IConfiguration myconfig;
<h3>@myconfig["ParentSetting"]</h3>

enter image description here

儿童应用程序:

@inject IConfiguration myconfig;
 <h3>@myconfig["ChildSetting"]</h3>
 <h3>@myconfig["ParentSetting"]</h3>

enter image description here

我找不到与此相关的任何文档。

没有与覆盖虚拟应用程序设置相关的此类文档。

  • 您可以参考此SOThread,了解如何部署和使用虚拟应用程序。

  • 确保您没有在

    Web.config
    (如果有)或部署的
    appsettings.json
    文件中将环境设置为开发。

  • 另请参阅 this 来覆盖 Azure 应用服务的

    appsettings.json

© www.soinside.com 2019 - 2024. All rights reserved.