Troubleshoot a faulty Azure VM by using nested virtualization in Azure
This article shows how to create a nested virtualization environment in Microsoft Azure, so you can mount the disk of the faulty VM on the Hyper-V host (Rescue VM) for troubleshooting purposes.
In order to mount the faulty VM, the Rescue VM must use the same type of Storage Account (Standard or Premium) as the faulty VM.
Step 1: Create a Rescue VM and install Hyper-V role
Create a new Rescue VM:
Operating system: Windows Server 2016 Datacenter
Size: Any V3 series with at least two cores that support nested virtualization. For more information, see Introducing the new Dv3 and Ev3 VM sizes.
Same location, Storage Account, and Resource Group as the faulty VM.
Select the same storage type as the faulty VM (Standard or Premium).
After the Rescue VM is created, remote desktop to the Rescue VM.
In Server Manager, select Manage > Add Roles and Features.
In the Installation Type section, select Role-based or feature-based installation.
In the Select destination server section, make sure that the Rescue VM is selected.
Select the Hyper-V role > Add Features.
Select Next on the Features section.
If a virtual switch is available, select it. Otherwise select Next.
On the Migration section, select Next
On the Default Stores section, select Next.
Check the box to restart the server automatically if required.
Allow the server to install the Hyper-V role. This takes a few minutes and the server will reboot automatically.
Step 2: Create the faulty VM on the Rescue VM’s Hyper-V server
Create a snapshot disk for the OS disk of the VM that has problem, and then attach the snapshot disk to the recuse VM.
Remote desktop to the Rescue VM.
Open Disk Management (diskmgmt.msc). Make sure that the disk of the faulty VM is set to Offline.
Open Hyper-V Manager: In Server Manager, select the Hyper-V role. Right-click the server, and then select the Hyper-V Manager.
In the Hyper-V Manager, right-click the Rescue VM, and then select New > Virtual Machine > Next.
Type a name for the VM, and then select Next.
Select Generation 1.
Set the startup memory at 1024 MB or more.
If applicable select the Hyper-V Network Switch that was created. Else move to the next page.
Select Attach a virtual hard disk later.
Select Finish when the VM is created.
Right-click the VM that you created, and then select Settings.
Select IDE Controller 0, select Hard Drive, and then click Add.
In Physical Hard Disk, select the disk of the faulty VM that you attached to the Azure VM. If you do not see any disks listed, check if the disk is set to offline by using Disk management.
Select Apply, and then select OK.
Double-click on the VM, and then start it.
Now you can work on the VM as the on-premises VM. You could follow any troubleshooting steps you need.
Step 3: Replace the OS disk used by the faulty VM
After you get the VM back online, shut down the VM in the Hyper-V manager.
If you are having issues connecting to your VM, see Troubleshoot RDP connections to an Azure VM. For issues with accessing applications running on your VM, see Troubleshoot application connectivity issues on a Windows VM.