Hi Everyone,
This blog post walks you through the manual process of adding an Azure virtual machine that uses managed disk to an availability set using a manual process purely inside the Azure portal (https://portal.azure.com).
This blog assumes you have a great understanding of what is an availability set, if you don’t know what this is, please refer to Azure availability sets guidelines for Windows VMs and Manage the availability of Windows virtual machines in Azure. It also assume that you have the concepts of managed disks in Azure, if not, please refer to Azure Managed Disks Overview.
Finally we need the following items already deployed in Azure:
- Availability set aligned to be used with managed disks
- The virtual machine using managed disks that is not yet associated with an availability set
This example also assumes that you don’t have any data disk attached to your virtual machine, if that’s the case you need to change the dataDisks in a similar way I do with the osDisk property.
Steps
- Sign in at https://portal.azure.com
- Export the current template definition of you live resource (virtual machine in this case)
- At the top navigation bar of Azure Portal, click in the search field and type “resource explorer”
- Click on “resource explorer”
- Easiest way to navigate over your resources is expanding Subscriptions->Subscription Name->Providers->Microsoft.Compute->virtualMachines->VM Name
- On the details pane, where the template shows up, copy all its template contents and save it locally with notepad or any tool you may find appropriate.
- Close “Resource Explorer”
- Click on “+ New”, at the search field, type “template deployment” and press enter
- Select “Template Deployment” from the “Everything” blade and click “Create”
- At the “Custom deployment” blade, click “Edit template”. This will bring a bring a blank template structure.
- At line 5, between the square brackets “[]”, paste the template you saved in the file.
Blank template
- Delete the line that contains “vmId” property, in this guide this is line 7
- Replace the contents of imageReference:
- From
"imageReference": {
"publisher": "OpenLogic",
"offer": "CentOS",
"sku": "7.3",
"version": "latest"
},
- To
"imageReference": null,
- From
"osDisk": {
"osType": "Linux",
"name": "centos02",
"createOption": "FromImage",
"caching": "ReadWrite",
"diskSizeGB": 31
},
- To
"osDisk": {
"createOption": "Attach",
"osType": "Linux",
"managedDisk": {
"id": "<Resource ID of your OS Disk>"
}
},
Where <Resource ID of your OS Disk> needs to point to the resource ID of the currently existing OS Disk, which can be obtained by searching for the disk in the search field of the top navigation pane and copying the Resource ID property (note that you need to open a new tab on your internet browser)
- From
"osProfile": {
"computerName": "centos02",
"adminUsername": "pmcadmin",
"linuxConfiguration": {
"disablePasswordAuthentication": false
},
"secrets": []
},
- To
"osProfile": null,
"apiVersion": "2016-04-30-preview"
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"resources": [
{
"properties": {
"hardwareProfile": {
"vmSize": "Standard_A1"
},
"storageProfile": {
"imageReference": null,
"osDisk": {
"createOption": "Attach",
"osType": "Linux",
"managedDisk": {
"id": "/subscriptions/<GUID>/resourceGroups/TEST03-RG/providers/Microsoft.Compute/disks/centos02"
}
},
"dataDisks": []
},
"osProfile": null,
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/<GUID>/resourceGroups/test03-rg/providers/Microsoft.Network/networkInterfaces/centos0287"
}
]
},
"provisioningState": "Succeeded"
},
"type": "Microsoft.Compute/virtualMachines",
"location": "westus",
"id": "/subscriptions/<GUID>/resourceGroups/test03-rg/providers/Microsoft.Compute/virtualMachines/centos02",
"name": "centos02",
"apiVersion": "2016-04-30-preview"
}
]
}
If any errors come up, you can always click in the notification icon at the top navigation pane and select the failed deployment:
This will bring the failed deployment blade
Then just click on “Redeploy” button so you can edit the template and fix any issues.
If you have virtual machines using unmanaged disks that needs to be included in an availability set, you can use a PowerShell module that I developed and poste at the TechNet Gallery using this link.
That’s it for this blog and I hope this helps.