Sometimes the Virtual Machine breaks down and can’t be restored from the backup. It can occur both if there is no backup and if the backup didn’t work for some reason. Fixing non-bootable VM can be complicated and time-consuming task. In this post I will describe how to fix non-booting VM using az cli commands.

First thing you should consider when creating any new Azure VM (it can be enabled for existing VMs too) is Boot Diagnostics. The Boot Diagnostics gives the ability to see your VM status on the screenshot in Azure Portal. Based on that, one can see what kind of error prevented the VM from working normally (More about Boot Diagnostic can be read on official Microsoft Page:

Once discovered the root-cause of an issue one can start working on remediating it. Microsoft provides us a command, which can help remediate the non-booting Virtual Machine. Below I will describe two ways of fixing your VM using  “az vm repair” command  (more information can be found on Microsoft related page:

Repair script:

Nested VM:

If running repair script didn’t solve the issue, you can create repair VM with enabled nested Hyper-V. This operation allows more advanced troubleshooting.

Now you can RDP to Your repair VM and inspect nested VM.

Repairing Nested VM using WindowsRE:

In this example I will run “sfc/ scannow” command – it will have the same effect as repair script. Firstly, one needs to find out the letter associated with Windows partition. In order to do that, I use BCDEdit command. Once the correct partition letter is found, one can start sfc scan by running “_**sfc /scannow /offbootdir=D: /offwindir=D:Windows”.**_

After a couple of minutes we get command results – all corrupted files were repaired. Now we can finish the whole process by switching OsDisk and removing repair VM – “az vm repair restore -g broken-vm-01 -n broken-vm-01 –verbose”. We confirm VM deletion.


Leave a Reply

Your email address will not be published. Required fields are marked *