Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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:

Colons are fine on an Azure App Service

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

Colons are not fine on Azure App Service for Linux

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....

like image 492
John Reilly Avatar asked Jul 23 '18 13:07

John Reilly


1 Answers

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.

To read a little more (not much more), I wrote this up as a blog post here: https://blog.johnnyreilly.com/2018/07/28/azure-app-service-web-app-containers-asp-net-nested-configuration/

like image 192
John Reilly Avatar answered Oct 17 '22 17:10

John Reilly