Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure App Services Add array of strings in configuration

Net core application and deploying the application in Azure App Services. In my application, I have an app settings.json file with below content

"Roles": {
    "Roles": [
        "Admins",
        "Users"
    ]
}

I have the below configuration in my ARM template.

Parameters.json

"Roles": {
    "value": [
        "Admins",
        "Users"
    ]
}

I am trying to add values in app settings as below

{
    "name": "Roles__Roles",
    "value": "[parameters('Roles')]" 
}

This is giving me an exception

2021-01-19T10:25:17.0538350Z ##[error]Details:
2021-01-19T10:25:17.0539754Z ##[error]undefined: HTTP request body must not be empty.

Can someone help me to fix this?

like image 265
Niranjan Godbole Hosmar Avatar asked Dec 07 '25 03:12

Niranjan Godbole Hosmar


1 Answers

As far as I understand, the app settings values provided for the App Service need to be of type string. However, your parameter "Roles" is of type array. Thus, a conversion to string is required. Try this:

{
    "name": "Roles__Roles",
    "value": "[string(parameters('Roles'))]"
}

The same applies to parameters of type object.

Unfortunately, the error message is not at all helpful in clarifying this.

References:

  • Microsoft Docs: Template functions - string - Azure Resource Manager
  • Related question: Error passing an array type as a parameter to an appsetting for an AppService Slot
like image 124
SvenEV Avatar answered Dec 08 '25 22:12

SvenEV