In today’s Azure Nugget I wanted to talk about how to redeploy a virtual machine in Azure to a new node? Recently I was working on a POC for a customer and deployed several VMs. One of the VMs just seemed to be having a hard time as it took quite a while to deploy. Once deployed I tried to connect to the VM using RDP. I received the RDP file and login screen and was able to establish connection but the desktop never came up. I simply had a black screen. I attempted a restart but that didn’t help. Azure has this concept of being able to redeploy a VM (support for Windows or Linux) to a new node so I figured it couldn’t hurt. There are two ways to accomplish this, via the Azure Portal or PowerShell. Let’s take a look at this.
In the Azure Portal, by clicking on a VM and going to its settings you will find a setting called “Redeploy” under the Support + Troubleshooting section. Clicking on “Redeploy” will open the Redeploy Virtual Machine blade. Simply clicking on the Redeploy button will migrate the VM to a new host in Azure. Keep in mind that this will cause the VM to restart and you will lose any data stored in the temp drive, since the temp drive is carved out from the host itself.
During this migration you will see the Status of the VM change from “Running” to “Updating” to “Starting” and finally “Running” again. This only took a few minutes to complete. Once it was done I was able to connect to the VM using RDP with no issues. Microsoft is trying to provide us with as many tools as necessary to avoid having to open a Support Request for issues that can be easily solved.
Although this is so simple to do in the portal, you can do this using PowerShell if you so desire via this one-liner.
Set-AzureRmVM -Redeploy -ResourceGroupName $rgname -Name $vmname
In addition, if you haven’t checked out Azure Resource Health, have a look as it may help you out when issues arise. I hope this Azure Nugget has been helpful.