应用服务计划无法在 azure devops 中的发布管道期间覆盖应用设置中的嵌套 JSON 键

App Service Plan Unable to override nested JSON keys in app settings during release pipeline in azure devops

网络核心应用。我的 appsettings.json 如下所示。

{
  "AzureAd": {
    "Authority": "https://login.microsoftonline.com/",
    "TenantId": "mytenantid",
    "ClientId": "myclientid"
  },
  "ApplicationInsights": {
    "InstrumentationKey": "myinstrumentationkey"
  },
  "EnableSwagger":"true"
}

我将我的应用程序部署到 Azure 应用程序服务。我在应用服务计划中有以下应用设置。

AzureAd:Authority
AzureAd:ClientId
AzureAd:TenantId
ApplicationInsights:InstrumentationKey
EnableSwagger

我面临的问题是,每当我将我的应用程序部署到 azure 应用程序服务中时,应用程序服务配置中的 EnableSwagger 值只会变为 appsettings.json。所以 Key:Value 种配置工作正常。嵌套对象键的问题

"AzureAd": {
        "Authority": "https://login.microsoftonline.com/"
           }

此值不会从应用服务配置应用设置覆盖到我的应用程序 appsettings.json。但是我只有“Key”:“Value”的地方是最重要的。我花了整整一天,无法弄清楚这个问题。我也尝试将 appservice 配置更改为低于 syntex,因为它是 Linux。 AzureAd:Authority 我将 : 替换为 __(双下划线)这对我也有用吗?此外,只有当我通过发布管道部署应用程序时才会发生这种情况。如果我通过右键单击解决方案并配置应用程序服务并单击发布来手动部署。有用。我在发布管道中面临的唯一问题。有人可以提出一些想法来解决这个问题吗?任何帮助真的很感激。谢谢

如果您想覆盖 Azure 应用服务的应用设置。您可以在发布管道中使用 azure app deployment taskApp settings 字段。

1,首先您可以在发布管道变量选项卡中定义变量来保存应用程序设置。见下文:

2、然后可以覆盖Azure应用服务部署任务中的应用设置。

进入Application and Configuration Settings--> App settings-->Click the 3dots--> Add the key-value.(你可以通过包装来引用变量$() 中的变量名称,或者您可以只设置值而无需在“变量”选项卡中定义变量。)

发布部署后。应覆盖应用服务计划中的应用设置。