Home > database >  Cannot concat two arrays in ARM template
Cannot concat two arrays in ARM template

Time:09-07

Given two variables of type array in an ARM template, using concat gives me:

The template variable 'thirdArray' is not valid: Unable to evaluate language function 'concat': al
l function arguments must be string literals, integer values, boolean values or arrays.

All function arguments are arrays, so I don't see what's wrong.

"variables": {
  "firstArray": {
    "type": "array",
    "value": [
      "1-1",
      "1-2",
      "1-3"
    ]
  },
  "secondArray": {
    "type": "array",
    "value": [
      "2-1",
      "2-2",
      "2-3"
    ]
  },
  "thirdArray": {
    "type": "array",
    "value": "[concat(variables('firstArray'), variables('secondArray'))]"
  }
}

CodePudding user response:

Looking at the documentation, your syntax is incorrect:

When defining a variable, you don't specify a data type for the variable. Instead provide a value or template expression. The variable type is inferred from the resolved value.

This works for me:

"variables": {
  "firstArray": [
    "1-1",
    "1-2",
    "1-3"
  ],
  "secondArray": [
    "2-1",
    "2-2",
    "2-3"
  ],
  "thirdArray": "[concat(variables('firstArray'), variables('secondArray'))]"
}
  • Related