Created
May 2, 2020 12:48
-
-
Save rndazurescript/15133465a804d7bbeff0478b3f8d3ea6 to your computer and use it in GitHub Desktop.
Reset Lease state for an azure blob storage container that is in broken state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from azure.storage.common.cloudstorageaccount import CloudStorageAccount | |
# Retrieve the storage account and the storage key | |
import json | |
settings= {} | |
with open('./settings.json') as f: | |
settings = json.load(f) | |
account_name = settings["STORAGE_ACCOUNT_NAME"] | |
account_key = settings["STORAGE_ACCOUNT_KEY"] | |
# The container that has Lease status broken | |
container_name='test-lease' | |
# Create a blobservice client from a storage account client | |
account = CloudStorageAccount(account_name, account_key) | |
blobService = account.create_block_blob_service() | |
# Get a container lease | |
lease_id=blobService.acquire_container_lease(container_name, lease_duration=-1) | |
# Release that lease | |
blobService.release_container_lease(container_name,lease_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment