Using copy function to deploy application in multiple regions ARM template

Viewed 28

I am trying to deploy some resources in multiple regions using copy() function. The template was works fine when being deployed in single region but as aI add copy function and use concat to give resource new name the copyindex doesnt work

Here is the location parameter

        "locations": {
            "type": "array",
            "defaultValue": [
                {
                    "location": "region1",
                    "suffix": "r1"
                },
                {
                    "location": "region2",
                    "suffix": "r2"
                }
            ]
        },

and the resource I am trying to create

  "resources": [
        {
            "copy" : {
                "name": "webappCopy",
                "count": "[length(parameters('locations'))]"
            },
            "type": "Microsoft.Resources/deployments",
            "apiVersion": "2019-10-01",
            "name": "[concat('WebApplication', parameters('locations')[copyIndex()].suffix)]",
            "dependsOn": [
                "[resourceId('Microsoft.Resources/deployments', concat('KeyVaultSecrets',parameters('locations')[copyIndex()].suffix))]"
            ],
            "properties": {
                "mode": "Incremental",
                "templateLink": {
                    "uri": "[parameters('webAppTemplateLink')]",
                    "contentVersion": "1.0.0.0"

The parameters file is in parameters folder

Template.WebApp.json

The error I am getting:

New-AzResourceGroupDeployment:
InvalidTemplate - Long running operation failed with status 'Failed'. Additional Info:'Deployment template validation failed: 'The template resource '[concat('WebApplication', parameters('locations')[copyIndex()].suffix)]' at line '1' and column '4124' is not valid: The language expression property 'suffix' can't be evaluated..
0 Answers
Related