Screenshot%202022-10-17%20at%208.51.56%20AM

How to Repair virtual machine

If your Windows virtual machine (VM) in Azure encounters a boot or disk error, you may need to repair the disk offline. A common example would be a failed application update that prevents the VM from being able to boot successfully.

This article details how to use Azure VM repair commands to automatically attach a broken OS disk to another Windows VM for offline repair. Through this procedure, the failed OS disk will automatically be unlocked on the second VM, called a repair VM, if the disk is encrypted with Azure Disk Encryption.

When the failed disk is attached to the repair VM, you can fix any errors and then rebuild your original VM with the repaired disk.

Repair virtual machine: guide

You can now use Azure VM repair commands to change the OS disk for a VM, and you no longer need to delete and recreate the VM.

Follow these steps to troubleshoot the VM issue:

  1. Launch Azure Cloud Shell
  2. Run az extension add/update.
  3. Run az vm repair create.
  4. Run az vm repair run, or perform mitigation steps.
  5. Run az vm repair restore.
  6. To view all available VM repair commands and parameters, see az vm repair.

To run the commands, you need a role that can create the following types of resources in the subscription:

  • Resource Groups
  • Virtual Machines
  • Resource Tags
  • Virtual Networks
  • Network Security Groups
  • Network Interfaces
  • Disks
  • Public IP Addresses (Optional)

Learn how to repair virtual machine VMware!