Creating Blob in Azure Blob Storage with the same name at the same time

I have a task to upload some images to the blob repository at the same time. The name blob is defined as md5 blob. It may happen that different threads try to download the same files from different places.

Now I need to know how to block other threads from loading the same file, if you are trying to download such a blob first.

+6
source share
1 answer

You can do this without leasing using optimistic concurrency. Basically set an access condition that says that this blob will be different from all etags blobs with that name. If in fact there is a blob with some stage, the second download will fail.

var access = AccessCondition.GenerateIfNoneMatchCondition("*"); await blobRef.UploadFromStreamAsync(stream, access, null, null); 
+5
source

Source: https://habr.com/ru/post/979691/


All Articles