There is a situation Windows Azure Virtual machines where either you have deleted the Virtual Machines for any reason or Virtual Machine is deleted due some other reason. You may have already know that the OS disk vhd is still saved in your Azure Storage because when virtual machine is deleted the OS disk and other data disk are still saved at their respective Windows Azure Storage location
When you want to reuse the OS disk vhd you might encounter the following problems:
1. You can see that OS Disk is still showing attached to Virtual Machine as shown below.
2. You can deleted the OS VHD from storage as while deleting VHD you get the following error:
Error deleting blob ‘/vhds/avkashsql2012-avkashsql2012-2012-07-18.vhd’: details
There is currently a lease on the blob and no lease ID was specified in the request.
3. If you decide to use the same OS VHD to create an OS image for creating your Virtual Machine, you will get error as below:
The VHD http://portalvhds63*.blob.core.windows.net/vhds/avkashsql2012-avkashsql2012-2012-07-18.vhd is already registered with image repository as the resource with ID avkashsql2012-avkashsql2012-0-20120718183454.
The bottom line is OS VHD is there but you cannot use it for any purpose.
– The root cause of this problem is that the VHD blob is still in lease due to some code issue and locked up in a way that it is not re-usable until you break the lease so it is free to use.
You cannot remove the blob lease directly at portal so you would need to use the PowerShell script as described below:
To delete OS VHD blob:
– If you have to delete the blob the you must need to break the least first and only then you would be able to delete
To reuse the OS VHD blob to create OS Image:
If you are looking for an alternative solution using the OS VHD to create an OS image and then use OS image to quickly create new Virtual Machine here is the solution.
– Download CloudXplorer
– Configured you Azure Blob Stroage where your locked OS VHD is stored. You can get this info from portal.
– Now access the OS VHD you want to reuse:
– Try renaming the VHD which will return ERROR as below:
– However even after the error you will see the rename did worked as below:
– This new OS VHD blob is ready to use as it is brand new.
– Now go back to Windows Azure Portal and access
- Virtual Machines -> Images -> Create Image (+)
- Route to your vhd container and then select your newly created VHD as shown below:
– You can now see that a new OS Image is created as below in Virtual Machines > Images section as below:
– Finally now you use this newly created OS Image to create a new Virtual Machines as below: