I'm using ARM template to create 4 SHARED disks and 3 VMs. Is there a way to attach these disks only to one node ?
below is my code for disk creation,
{
"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
}
}
below is the code for VM creation,
{
"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": {...}
}
}
since I'm attaching multiple disks adding dataDisks to properties in VM resource will attach disks to all VMs parallelly which will result in failure (shared disks cannot be attached parallelly to multiple VMs).
Is there a way to achieve attaching shared disk to only one VM (through VM resource) or after all VMs are created ?
I would create additional step in ARM with adding Powershell Deployment Script
But you will need service principal with abbilities to modify the disks.