question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Cannot delete single Blob Storage snapshot

See original GitHub issue

Library name and version

Azure.Storage.Blobs 12.8.0

Describe the bug

I can create a snapshot, but the SDK only allows me to delete all snapshots for a given blob item, not the one I specified. In general, the SDK usability of blob storage snapshots is very poor.

Expected behavior

Expected to be able to specify deleting a single snapshot

Actual behavior

Can only delete all snapshots

Reproduction Steps

BlobContainerClient blobContainerClient = new BlobContainerClient(/* auth */);
BlobClient blobClient = blobContainerClient.GetBlobClient("foo");
Response<BlobSnapshotInfo> snapshot = blobClient.CreateSnapshot();
blobClient.Delete(DeleteSnapshotsOption.OnlySnapshots); // no overload to specify a single snapshot
blobClient.WithSnapshot(snapshot.Value.Snapshot).Delete(); // returns BadRequest since this operation is only allowed on the base blob, not a snapshot

Environment

Developing .NET Standard 2.1 library project in Visual Studio 2019 on Windows 11, deploying to Azure AppService for Linux

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
peter-dolkenscommented, May 16, 2022

@aaronpburke - it’s possible, though not very obvious with the supplied documentation.

var blobClient = containerClient.GetBlobClient(blobPath);
var snapshotClient = blobClient.WithSnapshot(blobSnapshot);
await snapshotClient.DeleteAsync(cancellationToken);

The key is to get yourself the snapshotClient instead of the blobClient - then just perform the same actions you would as if it were a regular blob.

From the rest api documentation:

Any Blob service operation that is valid for a snapshot can be called by specifying ?snapshot=<DateTime> after the blob name.

0reactions
amnguyecommented, Jul 11, 2022

Closing the issue, please reopen if the sample above does not resolve the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

deleting from azure blob - Microsoft Q&A
Delete Blob : The Delete Blob operation marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection....
Read more >
Can an Azure container with a blob that has a snapshot be ...
I know that an Azure blob with snapshots cannot be deleted until all the snapshots are deleted. Would it be possible, though, to...
Read more >
Fix: unable to delete an Azure Storage Container due to a lease.
A quick tip for anyone who gets stuck when trying to delete an Azure Blob Storage Container that appears to be empty but...
Read more >
How to recover accidental deletes in Azure Blob Storage
This article covers soft delete feature in Azure Blob Storage to recover data that is accidentally deleted in blobs or blob snapshots.
Read more >
Delete an Amazon EBS snapshot - AWS Documentation
Delete a snapshot of an Amazon EBS volume using the AWS Management Console, ... Deleting a snapshot might not reduce your organization's data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found