Configuring AppSettings with ASP.Net Core on Azure Web App for Containers: Whither Colons?

大兔子大兔子 提交于 2020-03-17 10:45:27

问题


Consider this appsettings.json:

{
  "Parent": {
    "ChildOne": "C1 from secrets.json",
    "ChildTwo": "C2 from secrets.json"
  }
}

According to Microsoft (https://blogs.msdn.microsoft.com/waws/2018/06/12/asp-net-core-settings-for-azure-app-service/), if an app using this config was deployed to an AppService in Azure, the config could be overwritten by creating Application settings in Azure in the style Parent:ChildOne / Parent:ChildTwo. To be clear: using colons to target a specific piece of config.

This works just fine with a standard AppService:

However, if you're using Web App for Containers / i.e. a Docker image deployed to an Azure App Service on Linux (https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-linux-intro) you cannot use colons:

Why?

When you hover over the error you see this message: This field can only contain letters, numbers (0-9), periods ("."), and underscores ("_"). Using . does not work alas.

How do you configure say Parent:ChildOne in Azure? Parent.ChildOne does not work. Can anyone advise? I can't find any docs on this....


回答1:


After more experimentation than I'd like to admit I think I have the answer.

Where you use : on an App Service, use a __ (double underscore) on an App Service with containers.

So Parent__ChildOne instead of Parent:ChildOne.



来源:https://stackoverflow.com/questions/51480085/configuring-appsettings-with-asp-net-core-on-azure-web-app-for-containers-whith

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!