Azure CLI -create a Temp VM for a quick recovery . fix your Os and then just swap the Os and delete the Temp VM.

Hello All ,

On today sharing i wanted to introduce a new Azure Cli extension that can quickly been deploy a rescue vm and attach a copy of a OS disk VM with facing boot issue by a single command line.

So by one command we are deploying a new VM and attaching a copy of our Bad Os disk

And then by another command restoring it.

First we need to register the extension : az extension add -n vm-repair

Then it can be used.

https://docs.microsoft.com/en-us/cli/azure/ext/vm-repair/vm/repair

Machine generated alternative text:
tzach*zurew az vm repair create -g JumpBox -n Home -verbos 
Repair VM admin username: tzachie 
Repair VM admin password: 
Confirm Repair VM admin password: 
Fetching compatible Windows OS images from gallery... 
Checking if source VM size is available. 
Source VM size 'Standard_DS1_v2' is available. Using it to create repair WI. 
Creating resource group for repair VM and its resources... 
Source VM uses managed disks. Creating repair VM with managed disks. 
Validating VM template before continuing... 
Copying OS disk of source WI... 
Creating repair WI... 
Attaching copied disk to repair WI... 
Your repair VM 'repair-Home' has been created in the resource group ' repair-Home-2e19 
1007070154' with disk 'Home-DiskCopy-2e191ee7070154' attached as data disk. Please us 
e this VM to troubleshoot and repair. Once the repairs are complete use the command 
az vm repair restore -n Home -g Jump30x --verbose' to restore disk to the source WI. 
Note that the copied disk is created within the original resource group 'Jump30x' . 
"copied_disk_name . 
"Home-Diskcopy-2e191ee7e7e154", 
"copied_disk_uri " : 
"/ subscriptions/a55da7ce-ce8f-45dc-95f9-98cde685719d/ resourceGr 
ups/ umpBox/ providers /Mi c rosoft . Compute/ disks / Home- DiskCopy -2e191ee7e7e154" , 
"created resources" : 
"/subscriptions/a55da7ce-ce8f-45dc-95f9-98cde685719d/resourceGroups/REPAIR-HOME- 
e191ee7e7e154/ provi ders /Mic rosoft. Compute/ di sks / repair- Home_OsDi

So this create a new Temp VM and attach your OS disk as a data disk. Then you should to fix your Os issue .

once you are done

Run the below Restore command.

It will swap between the the fixed Os disk [Copy] with the original VM Os disk [corrupted] . deleted the temp resource group and VM components

Please confirm the Temp resource group and the VM and its dependencies are deleted if not please delete to avoid over costs.

For Example :

az group delete -g repair-scenarios-demo1-20200414184741.221389

Remember if you face any issue Feel free to raise a ticket to our wonderfully Azure support and an engineer will be happy to assist mitigate the issue.

Thank you , Tzachi Elkabatz

Close Bitnami banner