To troubleshoot Windows virtual machine in Azure that is inaccessible (e.g., due to boot issues or corruption) or sometimes, problems like a failed application update or windows updates can stop your VM from booting properly. In such cases, you can use snapshot and detach the OS, attach it to another working VM (repair VM) to troubleshoot and fix the problem.
In this post, we will go through the steps from taking snapshot, attaching the problematic disk to a repair VM to bringing the original VM back online. we can attach problematic OS disk to a working or repair VM and perform repair.
This method is useful when your VM fails to boot due to OS-level issues
Prerequisites:
- Access to the Azure portal
- Working VM or repair VM with Windows OS in the same region as the problematic VM
- Contributor or Owner role on the subscription/resource group
Follow the steps to Troubleshoot a Windows VM by Attaching the OS Disk to a Repair VM.
- Identify the Problematic VM
Go to the Azure Portal > Navigate to Virtual Machines and select the VM that is not booting. Note the resource group, location, and OS disk name. - Take a Snapshot of the OS Disk
Go to the Disks section of the VM in setting > Select the OS disk > go to Disk page > Click Create Snapshot.
Use default settings or customize as needed, then click Review + Create.
- Create a New Disk from the Snapshot
After the snapshot is created, go to the Snapshot resource > Click Create Disk.
Fill in the required details (name, resource group, region) > Click Review + Create. - Create a Repair VM if not available
In Azure Portal, Create a new Windows VM in the same region and resource group. Choose a size and image similar to the original VM. Complete the setup and create the VM. - Attach the OS Disk to the Repair VM
Go to the Disks section of the repair VM > Click + Add data disk > Select the new disk created from the snapshot > Save the configuration. - Connect to the Repair VM
Now use RDP to connect to the repair VM.
Open Disk Management and bring the attached disk online if needed.
Browse the disk to locate and fix issues (e.g., remove faulty drivers, fix or restore registry from "Regback" folder in C:\windows\System32\config\regback , etc.). - Detach and Replace the OS Disk
After repairs, detach the disk from the repair VM.
Go to the original VM’s Disks section. Click Swap OS Disk and select the repaired disk. Save and start the original VM.
Output:
If the issues (boot errors, registry corruption, etc.) are resolved, the VM should start normally. If not, you can repeat the process or consider restoring from backup or using the Azure VM Repair Script.
Want in more details? checkout Microsoft Article on this.