azure-sdk-for-net icon indicating copy to clipboard operation
azure-sdk-for-net copied to clipboard

[QUERY] Does Batch Delete support versioning?

Open RohanRao27 opened this issue 2 years ago • 11 comments

Library name and version

Azure.Storage.Blobs 12.13.0 & Azure.Storage.Blobs.Batch 12.10.0

Query/Question

Currently, using batch delete to delete multiple files. I am wondering if there is support to use the batch delete functionality to delete multiple versions of a single file. (e.g. 500 versions, delete 400 of them, given the 400 version ids?).

I have tried the following as a POC:

BlobBatchClient batchClient = _client.GetBlobBatchClient(); // _client is BlobServiceClient
BlobBatch batch = batchClient.CreateBatch();

Uri blobVersionToDelete = new BlobUriBuilder(_client.Uri) {
     BlobContainerName = "containerName",
     BlobName = "blobName",
     VersionId = "VersionId"
}

batch.DeleteBlob(blobVersionToDelete);
await batchClient.SubmitBatchAsync(batch,  throwOnAnyFailure: true);

And the entire blob is deleted instead of just the version specified. I am wondering if this a bug or if the feature is not supported. If its unsupported, an exception should be thrown stating version ids are not supported in batch delete instead of deleting the entire blob (in my opinion). (Uri Validation)

Environment

OS: Windows 10, .NET6 IDE: Visual Studio 2022 Version 17.2.5

RohanRao27 avatar Aug 16 '22 15:08 RohanRao27

Thank you for your feedback. This has been routed to the support team for assistance.

ghost avatar Aug 16 '22 17:08 ghost

@RohanRao27 Apologies for the late reply. Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

navba-MSFT avatar Sep 01 '22 04:09 navba-MSFT

@RohanRao27 Did you check if the below sample code without batching helps your requirement ?

blobContainerClient.GetBlobClient(blob.Name).WithVersion(blob.VersionId).DeleteAsync.

Awaiting your reply.

navba-MSFT avatar Sep 01 '22 07:09 navba-MSFT

Thank you for getting back to me @navba-MSFT

Yup that is the current workaround, but if there are many versions it will generate multiple network calls using that method, so batch would be ideal so that it can be handled in one network call. Just wondering if batch delete supports versioning at all/or if it is planned in a future release.

RohanRao27 avatar Sep 01 '22 16:09 RohanRao27

@RohanRao27 I am checking with the product owners and I will get back to you once I hear back from them.

navba-MSFT avatar Sep 07 '22 07:09 navba-MSFT

Hi, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar Sep 14 '22 08:09 ghost

Sure thanks for letting me know, will await that response

RohanRao27 avatar Sep 14 '22 13:09 RohanRao27

@RohanRao27 Our Product Group team has added this test in Java which tests for blob batch delete on versioned blobs.

From the test case they added, it appears that batch deletion on versioned blobs does work. They have also added a check to see if the BlobClient exists after performing the deletion, and we get a 404 Response indicating that it no longer exists.

navba-MSFT avatar Sep 19 '22 04:09 navba-MSFT

Thanks for the response, I took a look at the code, and actually, while that test is doing as you state, the crux of the issue reported still remains. Since while the original version is indeed deleted using the blob batch client, the current version is also deleted. I re-tested and the same issue as reported in the original post persists.

To reproduce, I bet if the test also asserts that the current version still exists, the test will fail (while it should pass if it was actually supported).

Let me know.

Thanks,

Rohan

RohanRao27 avatar Sep 20 '22 21:09 RohanRao27

@RohanRao27 Thanks for getting back. After doing testing again and trying to pass versionId in the query parameters, turns out blob-batch does not support deletes for versioned blobs. And the response received while performing this operation is the following:

<Reason>This operation is only allowed on the root blob. Snapshot should not be provided.</Reason></Error>

The Information in my previous comment was indicating that the base blob was being deleted, not the versioned blobs. Apologies for the confusion.

I am following up if there are any plans in roadmap to add this feature in Blob Batch SDK. I will keep you posted.

navba-MSFT avatar Sep 21 '22 03:09 navba-MSFT

Appreciate the clarifications here @navba-MSFT , will await the responses.

RohanRao27 avatar Sep 21 '22 14:09 RohanRao27

@RohanRao27 I have confirmed from the Product Owners that this feature is not on our roadmap now. We recommend customers to delete blob version via the regular delete API or using the above mentioned workaround.

We have also created an internal workitem to check on feasibility of having this feature. We currently have no ETA for this. We will track this internally on our workitem and keep you posted on this thread. If you need any updates on this in future, feel free to reopen this thread. We would be happy to help.

navba-MSFT avatar Sep 26 '22 04:09 navba-MSFT

Thanks for the update. Will use the regular delete API for this use case on our end.

RohanRao27 avatar Sep 26 '22 13:09 RohanRao27