I know that we can acquire a lease on a blob for 60 seconds or infinite.For the following code:
var account = CloudStorageAccount.DevelopmentStorageAccount;
var blob = account.CreateCloudBlobClient().GetBlobReference("container/blob");
var leaseId = blob.AcquireLease();
blob.UploadByteArray(bytes);
blob.ReleaseLease(leaseId);
If uploadBtyeArray time varies depending on the file size.How do i keep renewing the lease until upload is completed.
Regards,
Vivek
After calling
AcquireLeaseyou can spin up a new thread that constantly renews the lease just before it expires. Once the upload is complete, you should simply abort the thread which does the auto-renew.You might want to look at the WazStorageExtensions by Steve Marx, which comes with an AutoRenewLease class (look at the DoOnce method). Internally, the
AutoRenewLeaseclass uses such a thread to a keep the lease: