'How to update dynamic array from Azure App Service Configuration

We have an Azure App Service.

It has some config settings that we want to be able to change easily using the Azure Portal > Configuration tool.

However the values are arrays, and we need to be able to remove/add to the array at runtime as part of the configuration of the app.

The structure of the appsettings.json config entries look like this:

{ 
    "Level1": [
        {
            "Key1": "Value1",
            "Key2": "Value2"
        },
        {
            "Key1": "Value1",
            "Key2": "Value2"
        }
    ],  
    "Level2": [
        {
            "Key1": "Value1",
            "Key2": "Value2"
        },
        {
            "Key1": "Value1",
            "Key2": "Value2"
        }
    ],  
    "Level3": [
        {
            "Key1": "Value1",
            "Key2": "Value2",
            "Key3": "Value3"
        },
        {
            "Key1": "Value1",
            "Key2": "Value2",
            "Key3": "Value3"
        }
    ]
}

Everything I read (i.e. https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0#naming-of-environment-variables) about using Azure App Service > Configuration interface states that we can access an array element using the index number in the name. But we don't know the index number until it comes time to add/remove elements in the array.

Question:

  1. How do we setup a dynamic array in Azure Portal Configuration tool?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source