我在使用以下json模板创建虚拟机时向虚拟机添加了多个数据磁盘。
"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": {
.......
}
}
}
}
]
此代码在创建单个虚拟机时工作正常,但在创建多个虚拟机时,计算机无法创建。这是因为为第一台机器的datadisks创建的vhd与其他机器相同。
有没有办法创建一个名称不同的vhd? 尝试传递复制索引,但不起作用。