Search code examples
c#azureasp.net-coreazure-web-app-service

Override an array in azure app service application settings


In my .NET Core application, I added an array to the appsettings.json, which looks like this:

{
  "SettingsA": {
    "PropA": [
        "ChildObjectA": {
          ...
        },
        "ChildObjectB": {
          ...
        }
    ]
  }
}

If I would like to override that value from Application Settings in my azure app service, so that it will have empty array:

{
  "SettingsA": {
    "PropA": []
  }
}

Is there a way to do this?

I tried to put

SettingsA:PropsA  ->  []

In the application settings, but it doesn't seem to override the value of appsettings.json


Solution

  • The answer here https://www.ryansouthgate.com/2016/03/23/iconfiguration-in-netcore/ is that you can override elements within an array or add additional elements but he says that you can't override the entire array, which seems strange.

    Syntax for overriding uses zero-based access such as SettingsA:PropA:0:Something and I have tried this on App Services and can confirm it works.