Leasing a blob and implementing distributed locks

As the same services of Azure consume the Blob storage as a service, it needed some features to be enabled for complex scenarios. One of these is to allow an Azure virtual machine to exclusively access a blob (a VHD, for example), preventing other clients to access it in any way. To provide this feature, Blob Storage has the lease function: a lock-like status in which a blob cannot be written by anybody except the one who owns the lease.

A blob can be leased for 15 seconds up to 60 seconds (or infinite), and it can be renewed as many times as needed (while it is still locked). This is particularly useful with page blobs as they can be updated with random writes. Indeed, the Azure virtual machines ...

Get Microsoft Azure Development Cookbook Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.