JSON 循环中的活动部署模板失败

JSON Template Failing with Active deployment in loop

我正在尝试创建一个在 Azure 中执行多个虚拟机然后加密磁盘的模板,大约 3 小时前我设法让它与 2 个虚拟机一起工作,但是当我在 Azure 中执行三个以上的虚拟机时循环我得到以下错误:

            "code": "DeploymentFailed",
        "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.",
        "details": [
          {
            "code": "Conflict",
            "message": "{\r\n  \"error\": {\r\n    \"code\": \"DeploymentActive\",\r\n    \"message\": \"Unable to edit or replace deployment 'updatevm': previous deployment 
from '12/29/2018 1:11:34 AM' is still active (expiration time is '1/5/2019 1:11:34 AM'). Please see https://aka.ms/arm-deploy for usage details.\"\r\n  }\r\n}"
          }
        ]
      }
    ]

有没有办法暂停,等待 updatevm 扩展完成?

我的加密代码部分是:

{
      "name": "[concat(parameters('VMNames'),copyIndex(),'UpdateEncryptionSettings')]",
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2015-01-01",
      "dependsOn": [
        "[concat('Microsoft.Compute/virtualMachines/', parameters('VMNames'),copyIndex(1))]"
      ],
      "properties": {
        "mode": "Incremental",
        "templateLink": {
          "uri": "[concat(parameters('_artifactsLocation'),'/nestedtemplates/encryptVm.json',parameters('_artifactsLocationSasToken'))]",
          "contentVersion": "1.0.0.0"
        },
        "parameters": {
          "vmName": {
            "value": "[concat(parameters('VMNames'), copyIndex(1))]"
          },
          "aadClientID": {
            "value": "[parameters('aadClientID')]"
          },
          "aadClientSecret": {
            "value": "[parameters('aadClientSecret')]"
          },
          "keyVaultName": {
            "value": "[parameters('keyVaultName')]"
          },
          "keyVaultResourceGroup": {
            "value": "[parameters('keyVaultResourceGroup')]"
          },
          "useExistingKek": {
            "value": "[parameters('useExistingKek')]"
          },
          "keyEncryptionKeyURL": {
            "value": "[parameters('keyEncryptionKeyURL')]"
          },
          "_artifactsLocation": {
            "value": "[parameters('_artifactsLocation')]"
          },
          "_artifactsLocationSasToken": {
            "value": "[parameters('_artifactsLocationSasToken')]"
          }
        }
      }
    },

让它依赖于之前的扩展,因为你没有提供确切的代码,它类似于:

"dependsOn": [
    "updatevm"
}

由于模板的结构,这并不完全有效,答案是使用串行复制模式一次只创建一个副本+

"copy": {
    "name": "storagecopy",
    "count": 4,
    "mode": "serial",
    "batchSize": 1
}

https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#resource-iteration