UPDATE 10/08/2013: There are currently no scenarios where manually breaking the lease via script or CloudXplorer, etc. is useful in resolving this issue, so the script has been removed from this post.
When attempting to create a VM using a VHD that was previously used by a different VM, you may receive the following error:
A lease conflict occurred with the blob <blob url>
This error is expected if an existing VM is using a disk, or if you are attempting to delete a VHD and it is still registered in the portal as either a disk or image underVirtual Machines, Disks or Images.
If you receive this error, first make sure the VHD is not in use by a VM:
- In the Windows Azure management portal, if the disk shows up under Virtual Machines,Disks, and the Attached To column is not blank, you should first remove that VM in theAttached To column by going to VM Instances, selecting the VM, then clickingDelete.
- If Attached To is blank, or the VM in the Attached To column was already removed, try removing the disk by highlighting it underDisks and clicking Delete Disk (this will not physically delete the VHD from blob storage, it only removes the disk object in the portal). If you have multiple pages of disks it can be easier to search for a specific disk by
clicking the magnifying glass icon at the top right.
- If Delete Disk is grayed out, or the disk is not listed underDisks, but you still cannot reuse it or delete it, review the options below.
Alternate method: make a copy of the VHD in order to reuse a VHD with a stuck lease
If you have removed the VM and the disk object but the lease remains and you need to reuse that VHD, you can make a copy of the VHD and use the copy for a new VM:
- Download CloudXplorer. This will work with other
Windows Azure Storage Explorers but for the sake of brevity these steps will reference CloudXplorer.
- In the Windows Azure management portal, select Storage on the left, select the storage account where the VHD resides that you want to reuse, selectManage Keys at the bottom, and copy the Primary Access Key.
- In CloudXplorer, go to File, Accounts,New, Windows Azure Account and enter the storage account name in theName field and the primary access key in the Secret Key field. Leave the rest on the default settings.
- Expand the storage account in the left pane in CloudXplorer and select the
vhds container (or if the VHD in question is one uploaded to a different location, browse to that location instead).
- Right-click the VHD you want to reuse (which currently has a stuck lease), selectRename, and give it a different name. This will throw the error
could not rename…there is currently a lease on the blob… but click
Yes to continue, then View, Refresh (F5) to refresh and you will see it did make a copy of the VHD since it could not rename the original.
- In the Azure management portal, select Virtual Machines,
Disks, then Create Disk at the bottom.
- Specify a name for the disk, click the folder icon under VHD URL to browse to the copy of the VHD you just created, check the box forThis VHD contains an operating system, select the drop-down to specify if it isWindows or Linux, then click the arrow at the bottom right to create the disk.
- After the portal shows Successfully created disk <diskname>, selectNew at the bottom left of the portal, then Virtual Machine,From Gallery, My Disks, and select the disk you just created, then proceed through the rest of the wizard to create the VM.
Thanks,
Craig