4

I have five Azure blobs that correspond to five SQL azure database entries. Entity Framework allows me to delete the five database entries in one transaction e.g. see here: Multiple SaveChanges calls in entity framework. I want to delete the five blobs in one transaction also. So either none or all of the blobs are deleted. How do I do this? I intend to roll back my database transaction if any of the blob deletes fail, but so far I can only delete blobs one at a time.

Community
  • 1
  • 1
nmit026
  • 3,024
  • 2
  • 27
  • 53

1 Answers1

4

Each REST call to blob storage is independent; there are no transactions around multiple calls.

The only possible way of deleting multiple blobs within a single call (transaction) would be if all of the blobs were within the same container. You could then execute a delete on the container in a single call, which would also delete all the blobs within that container.

See here for API documentation, and here for the .net library call.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
  • Thanks David. I was afraid of that. Are there any reasons why the team didn't implement this? It seems a really useful thing to have. For example, each blob I'm uploading is a different size of the same photo. Each photo has some metadata stored in the database. This is pretty common. It doesn't make sense to upload or delete only some of them since the user will have to try again anyway if any of them fail, and if the user doesn't try again, then the data will be out of sync (result: broken URLs, or worse). Any plans to implement this in the future? – nmit026 Feb 09 '16 at 05:18
  • @nmit026 I agree that not having this very basic aspect of CRUD functionality is a pretty ridiculous oversight. Forcing us to delete blobs in a piecemeal fashion is nonsense. MSFT should prioritize this. – SB2055 Jun 28 '17 at 22:36
  • @SB2055 - feel free to post the suggestion to UserVoice, but no sense in voicing your opinion here. This isn't a Microsoft support forum. – David Makogon Jun 28 '17 at 22:55
  • within .net code would we be able to do something like this: `StartCopyAsync` on multiple blobs at the same time? – Alex Gordon Jul 15 '19 at 19:41