Just like any other storage with multiple users, Azure Blob storage must handle multiple users simultaneously. This is easy if all the concurrent users are trying to read the data, but when two or more users want to write to the Blob at the same time, this creates concurrency issues. To solve the issue of concurrent write access to a blob, the concept of Blob leasing has been provided in Azure Blob storage.
A blob lease enables the users to update a blob in a container while ensuring that no other user or process can modify or delete the blob until the update is complete. A blob can have only one active lease at a time. Another user can acquire a lease only after the lease has expired or released.
A lease can be either temporary, lasting 15 to 60 seconds or permanent i.e. until the lease is released.
The following five commands are available to manage Azure Blob storage lease:
- Acquire: This is a command for acquiring or starting a lease. User can specify whether the lease is temporary (with duration) or permanent.
- Release: This command specifies that the user wants to release the blob for leasing to another user.
- Renew: To renew a temporary lease for the same duration as specified at the time of acquiring the lease.
- Break: This specifies that the user intends to break or stop the lease but the blob cannot be acquired by other user until it has expired.
- Change: To change the ID property of the lease.
There are various interfaces through which the lease can be managed: Azure portal, Azure CLI, .NET, REST API etc.