问题
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