0

I have a Blob that I am accessing thus:

BlobContainerClient blobContainerClient = blobServiceClient.GetBlobContainerClient(Container);

BlobClient blobClient = blobContainerClient.GetBlobClient(key);
BlobLeaseClient blobLeaseClient = blobLeaseClientWrapper.GetBlobLeaseClient(blobClient);

blobLeaseClient.Acquire(TimeSpan.FromSeconds(60));

When I come to delete the blob using:

blobClient.Delete();

I get the error:

There is currently a lease on the blob and no lease ID was specified in the request

I've tried breaking the lease but I still get the same error:

blobLeaseClient.Break();
blobClient.Delete();

How do I delete a leased blob?

Liam
  • 27,717
  • 28
  • 128
  • 190

1 Answers1

2

This doesn't seem to be very well documented. The only reference I could find was this unhelpful response in the MSdocs github site and this old question about VMs from 2013.

A bit of digging in the classes unearthed this overload that seems to fix the problen:

 blobClient.Delete(DeleteSnapshotsOption.IncludeSnapshots, new BlobRequestConditions()
            {
                LeaseId = blobLeaseClient.LeaseId
            });
Liam
  • 27,717
  • 28
  • 128
  • 190