Azure ARM-将数组参数值传递给变量

Azure ARM- Passing array parameters values to Variables

我在这里尝试传递电子邮件值数组并将其引用给变量,以便它可以遍历每个值并且 deploy.My 要求是单独保存参数文件以便我只能触摸参数文件如果有任何更新(更多电子邮件详细信息)。我以这种方式尝试时遇到错误。请帮助我如何通过。

错误: 1.'为模板参数 'emailReceiverName' 在行 '1' 和列 '487' 提供的值无效。'。 2. "message": "至少有一个资源部署操作失败。请列出部署操作以获取详细信息。

#####TemplateDeployment.json######

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
    "actionGroupName": {
      "type": "array",
      "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": {
          "actionGroups": [
        {
            "EmailName": "[array(parameters('emailReceiverName'))]",
            "EmailAddress": "[array(parameters('emailReceiverAddress'))]"
        }
          ]
  } ,
"resources": [
    {
    "type": "Microsoft.Insights/actionGroups",
    "apiVersion": "2018-03-01",
    "name": "actionname",
    "location": "Global",
    "properties": {
        "groupShortName": "short",
        "enabled": true,
        "copy": [
            {
                "name": "emailReceivers",
                "count": "[length(variables('actionGroups'))]",
                "input": {
                    "name": "[variables('actionGroups')[copyIndex('emailReceivers')].EmailName]",
                    "emailAddress": "[variables('actionGroups')[copyIndex('emailReceivers')].EmailAddress]"

                }

                }

        ]
    }
}
    ]
}

**#####TemplateDeployment.json 到此结束 ######

##parameter.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": ["siva1","siva2",........]
        },
        "emailReceiverAddress": {
            "value": ["sa@ga.com","s@g.com",........]
        }

    }
}

好的,我不确定我是否理解正确(抱歉)。但我认为你只需要这一点:

{
    "name": "emailReceivers",
    "count": "[length(parameters('emailReceiverName'))]",
    "input": {
        "name": "[(parameters('emailReceiverName')[copyIndex('emailReceivers')]]",
        "emailAddress": "[(parameters('emailReceiverAddress')[copyIndex('emailReceivers')]]"
    }
}

然后删除这个变量 actionGroups