作为数组copy()的参数在资源中不起作用

时间:2018-11-30 05:37:26

标签: azure arm-template azure-template

我正在尝试将电子邮件值数组作为参数发送,并尝试使用资源模板中的“复制”来部署“操作组”。我的操作组模板已被正确部署,但电子邮件字段为空。我正在传递两个电子邮件值作为参数。我坚持了一天。如果有人对我要去的地方说一些话,那就太好了。

Template.json:

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "actionGroupName": {
            "value": "actiongroupslb"
        },
        "actionGroupShortName": {
            "value": "agSLB"
        },
        "emailReceiverName": {
            "value": ["siva","siva1"]
        },
        "emailReceiverAddress": {
            "value": ["siva@gmail.com","svaji@gmail.com"]
        }

    }
}

Parameter.json:

 var userRequest = new BoxUserRequest() 

   { Name = "test appuser", 
   IsPlatformAccessOnly = true, 
    Role = "Collaborator" };

appUser = client.UsersManager.CreateEnterpriseUserAsync(userRequest);

Action group created with missing email values

1 个答案:

答案 0 :(得分:0)

这是对我有用的东西:

    {
        "type": "Microsoft.Insights/actionGroups",
        "apiVersion": "2018-03-01",
        "name": "[variables('actionGroups')[copyIndex()].Name]",
        "copy": {
            "name": "ActionGroupCopy",
            "count": "[length(parameters('emailReceiverName'))]"
        },
        "location": "Global",
        "properties": {
            "groupShortName": "[variables('actionGroups')[copyIndex()].Name]",
            "enabled": true,
            "emailReceivers": [
                {
                    "name": "[variables('actionGroups')[copyIndex()].EmailName]",
                    "emailAddress": "[variables('actionGroups')[copyIndex()].EmailAddress]"
                }
            ]
        }
    },

这是变量:

    "actionGroups": [
        {
            "Name": "teamname",
            "EmailAddress": "email@domain.com",
            "EmailName": "emailname"
        },
        {
            "Name": "teamname1",
            "EmailAddress": "email1@domain.com",
            "EmailName": "emailname1"
        }
    ],

如果需要多个接收者,请使用资源属性复制功能,而不是资源:

{
    "type": "Microsoft.Insights/actionGroups",
    "apiVersion": "2018-03-01",
    "name": "name",
    "location": "Global",
    "properties": {
        "groupShortName": "name",
        "enabled": true,
        "copy": [
            {
                "name": "emailReceivers",
                "count": "[length(parameters('emailReceiverName'))]",
                "input": {
                    "name": "[parameters('emailReceiverName')[copyIndex('emailReceivers')]]",
                    "emailAddress": "[parameters('emailReceiverAddress')[copyIndex('emailReceivers')]]"
                }
            }
        ]
    }
},

这是假定他们一对一映射