0

我正在尝试将电子邮件值数组作为参数发送,并尝试在资源模板中使用“复制”部署“操作组”。我的操作组模板正在部署且没有错误,但电子邮件字段为空。我将两个电子邮件值作为参数传递。我坚持了一天。如果有人在我出错的地方投了一些灯,那就太好了。

模板.json:

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "actionGroupName": {
        "type": "string",
        "defaultValue": "newActionGroup",
        "metadata": {
            "description": "Unique name (within the Resource Group) for the Action group."
        }
    },
    "actionGroupShortName": {
        "type": "string",
        "defaultValue": "newActionGroup",
        "metadata": {
            "description": "Short name (maximum 12 characters) for the Action group."
        }
    },
    "emailReceiverName": {
        "type": "array",
        "metadata": {
            "description": "email receiver service Name."
        }
    },
    "emailReceiverAddress": {
        "type": "array",
        "metadata": {
            "description": "email receiver address."
        }
    }
},
"variables": {
    "customemailReceiverName": "[array(parameters('emailReceiverName'))]",
    "customemailReceiverAddress": "[parameters('emailReceiverAddress')]"
},
"resources": [
    {
        "type": "Microsoft.Insights/actionGroups",
        "name": "[parameters('actionGroupName')]",
        "apiVersion": "2018-03-01",
        "location": "Global",
        "properties": {
            "groupShortName": "[parameters('actionGroupShortName')]",
            "copy": [
                {
                    "name": "counts",
                    "count": "[length(parameters('emailReceiverName'))]",
                    "input": {
                        "emailReceivers": [
                            {
                                "name": "[parameters('emailReceiverName')[copyIndex('counts')]",
                                "emailAddress": "[parameters('emailReceiverAddress')[copyIndex('counts')]]"
                            }
                        ]
                    }
                }
            ]
        }
    }
] }

参数.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"]
        }

    }
}

创建的操作组缺少电子邮件值

4

1 回答 1

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')]]"
                }
            }
        ]
    }
},

这是假设他们映射 1 对 1

于 2018-11-30T05:58:21.183 回答