I am working on a use case where,
- Fetch the list of blob items from blob store using CloudBlockBlob.java client
- For each item acquiring a lease, processing it and deleting it.
Before deleting the item, i release the lease (since I know the lease id info) within that process.
I noticed that lease lock is used for write and delete operation in a multi process architecture.
Wanted to know will calling the CloudBlockBlob.deleteIfExists()
method will delete the leased blob item without any issues?
CodePudding user response:
Wanted to know will calling the CloudBlockBlob.deleteIfExists() method will delete the leased blob item without any issues?
CloudBlockBlob.deleteIfExists()
method without any parameters will not work if the blob has an existing lease on it. However if you release the lease (if you know the lease id) or break the lease (in case you do not know the lease id) before deleting the blob, then this method should work.
If the blob is leased at the time of deleting it and you know the lease id, you would need to use deleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext opContext)
. You will need to specify the access conditions for deleting the blob and there you would need to specify the lease id using generateLeaseCondition(String leaseID)