4
使用以下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": {
.......
}
}
}
}
]
此代码工作正常。这是因为第一台机器的datadisk创建的vhd与其他机器相同。
有没有办法用不同的名字创建一个vhd? 尝试传递复制索引,但不起作用。
运行上面的示例json时,我得到了以下错误:New-AzureRmResourceGroupDeployment:对象引用未设置为对象的实例。 在线:1 char:13 + $ response = New-AzureRmResourceGroupDeployment -ResourceGroupName $ ResourceGroup ... + ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ + CategoryInfo:CloseError:(:) [New-AzureRmResourceGroupDeployment],NullReferenceException + FullyQualifiedErrorId:Microsoft.Azure.Commands.Resources.NewAzureResourceGroupDeploymentCommand –
但虚拟机使用数据磁盘正确创建。 –
好吧,我不确定你在做什么错误,对我来说这工作正常,如果这样做你所要求的,接受这个答案;)我刚刚测试过这个部署,它工作正常。 '新AzureRmResourceGroupDeployment -Name测试-ResourceGroupName zxc -TemplateUri https:// raw.githubusercontent.com/4c74356b41/armotron/master/ml-vm-ml-dd.json' – 4c74356b41