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