覆盖 Azure 应用设置中的 appsettings.json 值

时间:2021-04-01 08:45:27

标签: asp.net azure azure-web-app-service

我有一组 appsetting vaues 如下。我们在 Windows 应用服务上

"MainDomains": {
"Domains": [
  {
    "Id": "123456",        
    "Domain": "Technical",       
    "PolicyUrl": "https://www.mytechdomain.net",
    "LearningPoint": "https://www.mytechdomain.net",
    "Hostnames": [
      "https://localhost:4567",
      "http://localhost:34565",          
      "https://mytechdomain.latestlearn.com"
    ],
    "UsePreviewContent": true,
    "IsDefault": true,
    "OriginEmail": "info@techdomain.net",
    "mytechname": "Techdomain"
  }
]

}

我将如何在配置下的 Azure 应用设置中正确设置这些值。我已经尝试过像 property1:property2:0 --> xxxvalue。然而,这似乎不起作用。我猜测可能是我在另一个数组中有一个数组。其中第一个数组是 MainDomains,MainDomains 数组中的另一个数组是 Domains。

1 个答案:

答案 0 :(得分:1)

您应该在 appsettings.json 中使用相同的分隔格式设置应用设置名称。但正如 Gaurav Mantri 所说,在门户网站上使用双下划线 __ 而不是 :

参考关于Configuration keys and values的说明:

<块引用>

在环境变量中,冒号分隔符可能不适用于所有 平台。所有平台都支持双下划线 __ 会自动转换为冒号 :

您还可以查看 official document about how to set App Settings

相关问题