Home > Net >  Azure Arm template copy function for VM and Datadisks
Azure Arm template copy function for VM and Datadisks

Time:12-24

I am using copy to create multiple VM's and want to have multiple datadisks for each vm. I know i can do it this way:

              {
              "name": "[concat('dataDisk-',parameters('vm-name'),'-0',copyIndex(1))]",
              "diskSizeGB": "[parameters('dataDisksize')]",
              "lun": 0,
              "createOption": "Empty"
              },
              {
              "name": "[concat('dataDisk1-',parameters('vm-name'),'-0',copyIndex(1))]",
              "diskSizeGB": "[parameters('dataDisksize')]",
              "lun": 1,
              "createOption": "Empty"
              }

Now I have to create 20 disks with the same name and this doesn't seem to be good workaround. Getting issue with disk name while using copy. For my case i can use the same disksize for all 20 disks

CodePudding user response:

You can use the copy element to repeat properties:

"copy": [
            {
              "name": "dataDisks",
              "count": "[parameters('numberOfDataDisks')]",
              "input": {
                "lun": "[copyIndex('dataDisks')]",
                "createOption": "Empty",
                "diskSizeGB": 1023
              }
            }
          ]

More information here: enter image description here

  • Related