我使用以下 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": {
.......
}
}
}
}
]
这段代码在创建单个虚拟机时运行良好,但在创建多个虚拟机时失败。这是因为为第一台机器创建的数据磁盘的vhd与其他机器相同。
有没有一种方法可以创建具有不同名称的vhd?尝试传递copy index,但不起作用。
+ CategoryInfo : CloseError: (:) [New-AzureRmResourceGroupDeployment], NullReferenceException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureResourceGroupDeploymentCommand
New-AzureRmResourceGroupDeployment -Name test -ResourceGroupName zxc -TemplateUri https://raw.githubusercontent.com/4c74356b41/armotron/master/ml-vm-ml-dd.json
- 4c74356b41