MathGeek
MathGeek

Reputation: 531

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

Upvotes: 2

Views: 7482

Answers (3)

ITHelp
ITHelp

Reputation: 1

I had the same issue. In my case a container was saying broken after removing the lease. Through the portal I deleted the container and then undeleted (only can do this if you have soft-delete enabled) and when the container was undeleted it reverted back to available.

Upvotes: 0

Erick Navarro
Erick Navarro

Reputation: 1

I had the same problem, but with a container. The solution is similar, with slightly different commands.

Here they are for PowerShell:

To acquire the lease:

$leaseId=az storage container lease acquire --account-name mystorageaccount --container-name mycontainer --account-key 0000-0000

To release the lease:

az storage container lease release --lease-id $leaseId --account-name mystorageaccount --container-name mycontainer --account-key 0000-0000

Upvotes: 0

Alex
Alex

Reputation: 18556

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.

Upvotes: 6

Related Questions