Home > front end >  Azure App Service - App Settings Array In Array
Azure App Service - App Settings Array In Array

Time:02-08

I am currently trying to create a "complex" appsettings structure in the Azure App Service configurations and I am failing.

My appsettings.json looks sth. like that:

{
"AgentPools": [
    {
      "Id": "1",
      "Name": "PoolName1",
      "AllowedProjects": []
    },
    {
      "Id": "2",
      "Name": "PoolName2",
      "AllowedProjects": [
        "myproject1",
        "myproject2"
      ]
    }
  ]
}

My problem is now, that it seems like that I´m doing sth wrong in the settings for that array in the array.

The configuration looks like that in Azure App Service (Linux):

  • AgentPools__0__Id -> 1 => working
  • AgentPools__0__Name -> PoolName1 => working

  • AgentPools__1__Id -> 2 => working
  • AgentPools__1__Name -> Poolname2 => working
  • AgentPools__1__AllowedProjects__0 -> myproject1 => not working
  • AgentPools__1__AllowedProjects__1 -> myproject2 => not working

Am I actually doing something wrong, or is it not even possible to build a somewhat more complex structure?

I´m programming in netcore.

CodePudding user response:

The example in this article suggest that you can overwrite array values only if the array has objects as nested properties, not values directly.

When the element structure includes an array, the array index should be treated as an additional element name in this path.

{
    "SmtpServer": "smtp.example.com",
    "Logging": [
        {
            "Name": "ToEmail",
            "Level": "Critical",
            "Args": {
                "FromAddress": "[email protected]",
                "ToAddress": "[email protected]"
            }
        },
        {
            "Name": "ToConsole",
            "Level": "Information"
        }
    ]
}
setx SmtpServer smtp.example.com
setx Logging__0__Name ToEmail
setx Logging__0__Level Critical
setx Logging__0__Args__FromAddress [email protected]
setx Logging__0__Args__ToAddress [email protected]
setx Logging__1__Name ToConsole
setx Logging__1__Level Information
  •  Tags:  
  • Related