Right now I'm making a HTTP serverless function with Azure Functions and with that I need to make my incoming requests synchronous when accessing a single Blob Storage Item on my Storage Account.
What I want to happen is the following:
// Incoming Request 1
// .. Get blob
await myBlob.AcquireLeaseAsync(TimeSpan.FromMinutes(1), leaseId);
// .. 10 seconds later
await myblob.ReleaseLeaseAsync(AccessCondition.GenerateEmptyCondition());
//
// MEANWHILE
//
// Incoming Request 2 (Happens 1-2 seconds after Request 1)
// .. Get blob
// .. -- Wait until Lease is released from Request 1 --
await myBlob.AcquireLeaseAsync(TimeSpan.FromMinutes(1), leaseId);
// Repeat...
However I noticed when I try to get Blob on Request 2, it doesn't synchronously wait until the Blob lease is released from Request 1, it simply just returns an error which says that there's already an active Lease on this blob, and then just continues.
Is it possible to have the above synchronous system in an Azure Function?
See Question&Answers more detail:os