none
Error when reusing existing disk for new VM: A lease conflict occurred with the blob

    Question

  • 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 under Virtual Machines, Disks or Images.

    You can also see this error if you are using New-AzureVMConfig to create a VM and the blob URL you are providing for -MediaLocation points to an existing blob.

    If you receive this error, first make sure the VHD is not in use by a VM:

    1. 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 the Attached To column by going to VM Instances, selecting the VM, then clicking Delete.
    2. If Attached To is blank, or the VM in the Attached To column was already removed, try removing the disk by highlighting it under Disks 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.
    3. If Delete Disk is grayed out, or the disk is not listed under Disks, 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:

    1. Download CloudXplorer. This will work with other Windows Azure Storage Explorers but for the sake of brevity these steps will reference CloudXplorer.
    2. In the Windows Azure management portal, select Storage on the left, select the storage account where the VHD resides that you want to reuse, select Manage Keys at the bottom, and copy the Primary Access Key.
    3. In CloudXplorer, go to File, Accounts, New, Windows Azure Account and enter the storage account name in the Name field and the primary access key in the Secret Key field. Leave the rest on the default settings.
    4. 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).
    5. Right-click the VHD you want to reuse (which currently has a stuck lease), select Rename, 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.
    6. In the Azure management portal, select Virtual Machines, Disks, then Create Disk at the bottom.
    7. 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 for This VHD contains an operating system, select the drop-down to specify if it is Windows or Linux, then click the arrow at the bottom right to create the disk.
    8. After the portal shows Successfully created disk <diskname>, select New 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


    Monday, July 30, 2012 2:34 PM
    Moderator

Answers

All replies

  • Hi Craig,

    Is there a way to resolve a situation where the portal shows OS and data disks as still being attached to a VM but the VM no longer exists?

    I had issues deploying a new VM earlier using existing OS and data disks, which I believe was due to the problems the service encountered in West Europe today, and now the portal shows these disks as being attached to a VM which never started.

    I appreciate the option to copy the disks would work but I'd rather not do this just to free them from a spurious lease.

    Thanks,

    Graham

    Wednesday, October 10, 2012 7:57 PM
  • Hello.

    I outline the process here: How to Remove an Orphaned Windows Azure Virtual Machine Disk and Remove a Lease Conflict on a VHD Blob

    Basically, you need to use PowerShell to call Remove-AzureDisk. The steps above outline how to set up PowerShell. It only takes a few minutes.<o:p></o:p>

    If you are looking for a way to break the lease, I have a simple tool to help with that as well as I wasn't able to get the above steps to work:  Windows Azure Virtual Hard Disk (blob storage) Cross Account Copy, Lease Break, and Management Tool

    Hope this helps.


    Stephen W. Thomas 8 Year BizTalk Server MVP http://www.BizTalkGurus.com

    Thursday, October 11, 2012 3:18 AM
  • Hey Craig I deployed a couple of SQL Server images from the gallery and subsequently deleted them.  After doing so the VHD's for both my OS disks and data disks were still laying around so I tried to manually delete them and got the lease error.  I used your script above and it works to kill the lease on some of the orphaned vhd files but not for others.  Specifically I get this error from your script:

    "The blob is still registered as a disk with name 'rd-sqleval-01-rd-sqleval-01-0-20120827183924'.  Please delete the disk first."

    Do you have a script that cleans up orphaned disks as well?

    Thanks!


    Roger Doherty (MSFT)

    Thursday, October 25, 2012 3:53 AM
    Answerer
  • You should be able to remove the Disk using Powershell.  I talk about the process in this blog post: http://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalk/archive/2012/09/19/how-to-remove-an-orphaned-windows-azure-virtual-machine-disk-and-remove-a-lease-conflict-on-a-vhd-blob.aspx

    It should just be "Remove-AzureDisk yourDiskName"

    Hope this helps!


    Stephen W. Thomas 8 Year BizTalk Server MVP http://www.BizTalkGurus.com



    Thursday, October 25, 2012 3:58 AM
  • Thanks Stephen I saw the link to your blog but the URL isn't working for me.  Could you double-check it?

    Roger Doherty (MSFT)

    Thursday, October 25, 2012 4:05 AM
    Answerer
  • Hi,

    I do not have disk under Virtual Machines -> Disks tab.

    1. I copied a vhd to new subscription

    2. created image using that copied vhd

    3. Using PowerShell, trying to create Virtual machine based on created image above.

    And I am getting the lease conflict error message.

    Any help on how to solve this when there are no disks present in Azure. PFB code that I am using to create VM

    New-AzureVMConfig -Name $VMToCreate -InstanceSize $InstanceSize -ImageName $vmImage -MediaLocation $imageLocation `
                | Add-AzureProvisioningConfig -WindowsDomain -AdminUsername $admin -Password $password -JoinDomain $domainName -Domain $domainName -DomainUserName $domainAdminUser -DomainPassword $Domainpassword `
                | Set-AzureSubnet -SubnetNames $subnet `
                | New-AzureVM -ServiceName $servicename -VNetName $vnet -ErrorAction SilentlyContinue


    • Edited by Sonam Rastogi Wednesday, August 12, 2015 11:37 AM Updated
    Wednesday, August 12, 2015 11:36 AM
  • On a new VM I had the same issue of lease conflict and it turned out the file was still copying even though when I copied the result was "successful".

    This command worked to check the status of the new file using Azure PowerShell:

    Get-AzureStorageBlobCopyState -Blob Myfile.vhd -Container Mycontainer

    Of course before running that you need to Add-AzureAccount and Set-AzureSubscription with -CurrentStorageAccountName Mystorageaccountname

    When it's in process the Status will be Pending, and when done will read "Success", but this time they mean it.  When Pending, check every few minutes and you will see the BytesCopied are increasing.

    I hope that helps!

    -Ryan

    Wednesday, October 21, 2015 2:52 PM