I added some virtual machines to virtual machines when creating virtual machines using the following json template.
"variables": {
"diskArray": [
{
"name": "datadisk1",
"lun": 0,
"vhd": {
"uri": "[concat('http://', variables('storageAccountName'),'.blob.core.windows.net/vhds/','datadisk1.vhd')]"
},
"createOption": "Empty",
"caching": "ReadWrite",
"diskSizeGB": 300
},
{
"name": "datadisk2",
"lun": 1,
"vhd": {
"uri": "[concat('http://', variables('storageAccountName'),'.blob.core.windows.net/vhds/', 'datadisk2.vhd')]"
},
"createOption": "Empty",
"caching": "ReadWrite",
"diskSizeGB": 200
},
{
"name": "datadisk3",
"lun": 2,
"vhd": {
"uri": "[concat('http://', variables('storageAccountName'),'.blob.core.windows.net/vhds/', 'datadisk3.vhd')]"
},
"createOption": "Empty",
"caching": "ReadWrite",
"diskSizeGB": 100
}
]
},
.....
.....
"resources": [
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(parameters('VmPrefix'), copyindex(1))]",
"copy": {
"name": "Datanode",
"count": "[variables('vmcount')]"
},
"location": "[resourceGroup().location]",
"properties": {
......
......
"storageProfile": {
"imageReference": {
........
},
"dataDisks": "[take(variables('diskArray'),parameters('numDataDisks'))]",
"osDisk": {
.......
}
}
}
}
]
This code works great when creating a single virtual machine, but when creating multiple virtual machines, machines were not created. This is because the vhd created for the datadisks for the first machine is similar to other machines.
Is there a way to create vhd with a different name? I tried to skip the copy index, but it does not work.