我正在使用 ARM 模板创建 4 个共享磁盘和 3 个虚拟机。有没有办法将这些磁盘仅附加到一个节点?
下面是我的磁盘创建代码,
{
"type": "Microsoft.Compute/disks",
"apiVersion": "2018-06-01",
"name": "[concat(variables('vmName'),'-datadisk1')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Premium_LRS"
},
"properties": {
"creationData": {
"createOption": "Empty"
},
"diskSizeGB": 1024,
"maxShares": 5
}
}
下面是创建虚拟机的代码,
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2018-10-01",
"name": "[variables('vmName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
"[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]"
],
"properties": {
"hardwareProfile": {...},
"osProfile": {...},
"storageProfile": {
"imageReference": {...},
"osDisk": {
"name": "osdisk",
"vhd": {...},
"caching": "ReadWrite",
"createOption": "FromImage"
},
},
"networkProfile": {...},
"diagnosticsProfile": {...}
}
}
因为我要附加多个磁盘,所以将 dataDisks 添加到 VM 资源中的属性会将磁盘并行附加到所有 VM,这将导致故障(共享磁盘不能并行附加到多个 VM)。
有没有办法实现仅将共享磁盘附加到一个 VM(通过 VM 资源)或在创建所有 VM 之后?