Azure ARM template - using array variable

Munchkin picture Munchkin · Sep 15, 2017 · Viewed 7.1k times · Source

I am defining an alertrule inside my template.json with custom eMails which shall be alerted in case of an error. So the JSON snippet looks like this:

"resources": [
    {
        "type": "microsoft.insights/alertrules",
        "properties": {
            "action": {
                "customEmails": [
                    "[email protected]",
                    "[email protected]"
                ]
            }
        }
    }
]

Now I'd like to store these emails as an array-variable, something like this:

"variables": {
    "alertEmails": [
        "[email protected]",
        "[email protected]"
    ]
},
"resources": [
    {
        "type": "microsoft.insights/alertrules",
        "properties": {
            "action": {
                "customEmails": "[variables('alertEmails')]"
            }
        }
    }
]

This doesn't work, but I didn't found out what the correct syntax is. Can someone tell me?

Answer

Jason Ye picture Jason Ye · Sep 15, 2017

If you want to use array, maybe we can use json like this:

"parameters": {    
"customEmailAddresses": {
                "type": "array",
                "defaultValue": ["[email protected]",
                    "[email protected]",
                    "[email protected]"]

  }
},

and in action, like this:

 "customEmails": "[array(parameters('customEmailAddresses'))]"