In some circumstances, you need to redeploy a virtual machine in Microsoft Azure, and the most common reason is when you can’t access the VM. Sometimes it is not a configuration issue but something on the host where the VM is located that is not allowing you to do it. The best option to troubleshoot and fix this kind of issue is using the Azure redeploy feature. When we decide to use this option, these are the tasks that are being performed in the backend:
- The VM is shut down by Azure.
- The VM is moved to a different node.
- The VM is started on the new node.
The Azure redeploy feature process does not impact your settings or configuration of the affected VM. The only thing that you may lose is the data on temporary disks — which you shouldn’t be using anyway. We can do this redeploy process using PowerShell, Azure CLI, and Azure Portal.
When using Azure Portal, click on the desired VM, and on its properties, select the option Redeploy and then confirm by hitting the Azure redeploy button.
If you want to use PowerShell, the best way is to find the VM name and resource group name and then use the Set-AzureRMVM cmdlet. The syntax of both cmdlets is listed below.
Get-AzureRMVM Set-AzureRmVM -ResourceGroupName “<ResourceGroupName>” -Name “<ServerName” -Redeploy
Featured image: Shutterstock