Linux – Recreate Azure virtual machine from existing and working disk

azurelinuxopensusevhd

This morning I found that my Azure VM was dead dead. It was impossible for me to reboot or shut it down.

Anyway I managed to delete the VM instance and make a snapshot copy of the VHD (who never knows…). After creating a new VM and mounting the existing disk I found that all files were in order, so I want to suspect a cluster failure at Azure.

Anyway I have a whole file system full of applications waiting to run again. Surely, reinstalling all software, cloning /etc, /home and other directories to a fresh new VM could be a feasible idea, but I'd like to go back online ASAP.

The problem is that when I go creating a new VM I find no available disk in the Personal Disks tab. But I was able to attach that disk to the fresh new VM. I can also see that disk in the Virtual Machines/Disks tab on Management Console. Actually, I'll have to report Microsoft that a few strange things are happening in that screen (out of question scope and suggesting a problem at Azure), like non-existing disk connecting to already-deleted VM.

So, the question is. Starting from a non-damaged VHD that already ran an Azure Linux VM image (openSuse 12.1, not patched according to this blog post), how do I create a new machine instance that boots with that disk?

Best Answer

The following is the normal procedure of recreating a VM with a working disk, plus some troubleshooting.

  1. Write down port mappings. You'll need them later
  2. Delete VM instance. This won't delete the disk as clearly stated by Management Portal
  3. Create a new VM from gallery. In the Disks tab you'll find your current VHD

If you don't see that... like what happened to me

  • Try to delete the disk mapping without deleting the VHD
  • Break the lease with CloudXplorer
  • Under Virtual Machines/Disks tab, create a new disk from the existing VHD that you have not deleted

And then you should see it when creating the new VM.

After creating the VM, wait for it to provision and don't click Start or you'll possibly get an error. I had to create the machine twice