azureazure-blob-storageazure-storageazure-storage-account

How to change the Lease state of Azure Blob to Available


I have an Azure storage account, and there is a blob in container. I clicked on acquire lease on that blob and the Lease state got changed from Available to Leased. Now I want to revert it back to Available. I clicked on Break Lease hoping it will revert the state to Available, but it changed the state to Broken

Now, the Lease state is changing between Leased and Broken, But I am not able to revert it to Available state. Any help on how to revert the lease state to Available?

enter image description here


Solution

  • You cannot do what you want by using the Azure Portal.

    A lease can only be cleanly released by using the lease id that was returned during the original lease operation.

    You can change the lease state to available manually by leasing and releasing the blob using Azure CLI, or any other SDK.

    https://learn.microsoft.com/en-us/cli/azure/storage/blob/lease?view=azure-cli-latest

    $leaseId=az storage blob lease acquire -b myblob -c mycontainer --account-name mystorageaccount --account-key 0000-0000
    az storage blob lease release --lease-id $leaseId -b myblob -c mycontainer --account-name mystorageaccount --account-key 0000-0000
    

    See also https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-container-lease for more general documentation.