Reputation: 16900
Is there a good way to create a temporay blob on Azure, then rename it after the upload is complete? I want to implement an atomic upload which should retain the original contents of the blob if the upload is aborted mid-way.
With "good", I mean something that would give me an available blob-name immediately and ideally "lock" it. For high access rates, even checking if a pseudo-temporary blob name already exists can be problematic when another application attempts to checks the same blob name.
Upvotes: 0
Views: 1214
Reputation: 643
I don't think you need to do the rename because, conveniently, blob uploads are already atomic. Blocks are uploaded in an uncommitted state, and then the final atomic step commits them by providing a list of their Ids. If that final step never happens, you won't see the blob at all (unless you explicitly ask for "uncommitted blobs", which you wouldn't normally do). See the remarks in the documentation for PutBlock and PutBlockList
(Ultimately, all Block Blob creation ends up calling either "PutBlob" (for small blobs) and which is atomic by definition; or a sequence of PutBlock calls followed by PutBlockList. E.g. the .NET Storage Client library uses CloubBlobStream, which calls those Put... functions to do its work)
Upvotes: 1
Reputation: 71130
Not quite sure I understand your use case, but you cannot rename a blob. You'd need to copy it to a new blob, to accomplish a rename.
Upvotes: 0