EchoVib

Class BlobLeaseClient | Azure SDK for Net

The BlobLeaseClient allows you to manipulate Azure Storage leases on containers and blobs.

Inheritance

BlobLeaseClient

Namespace: Azure.Storage.Blobs.Specialized
Assembly: Azure.Storage.Blobs.dll
Syntax
public class BlobLeaseClient

Constructors

BlobLeaseClient()

Declaration
protected BlobLeaseClient ();

BlobLeaseClient(BlobContainerClient, String)

Declaration
public BlobLeaseClient (Azure.Storage.Blobs.BlobContainerClient client, string leaseId = null);
Parameters

BlobLeaseClient(BlobBaseClient, String)

Declaration
public BlobLeaseClient (Azure.Storage.Blobs.Specialized.BlobBaseClient client, string leaseId = null);
Parameters
BlobBaseClient client

A BlobClient representing the blob being leased.

String leaseId

An optional lease ID. If no lease ID is provided, a random lease ID will be created.

Fields

InfiniteLeaseDuration

The TimeSpan representing an infinite lease duration.

Declaration
public static readonly TimeSpan InfiniteLeaseDuration;
Field Value

Properties

BlobClient

Declaration
protected virtual Azure.Storage.Blobs.Specialized.BlobBaseClient BlobClient { get; }
Property Value

BlobContainerClient

Declaration
protected virtual Azure.Storage.Blobs.BlobContainerClient BlobContainerClient { get; }
Property Value

LeaseId

Gets the Lease ID for this lease.

Declaration
public string LeaseId { get; }
Property Value

Uri

Gets the URI of the object being leased.

Declaration
public Uri Uri { get; }
Property Value

Methods

Acquire(TimeSpan, RequestConditions, CancellationToken)

The Acquire(TimeSpan, RequestConditions, CancellationToken) operation acquires a lease on the blob or container. The lease duration must be between 15 to 60 seconds, or infinite (-1).

If the container does not have an active lease, the Blob service creates a lease on the blob or container and returns it. If the container has an active lease, you can only request a new lease using the active lease ID as LeaseId, but you can specify a new duration.

For more information, see .

Declaration
public virtual Azure.Response<Azure.Storage.Blobs.Models.BlobLease> Acquire (TimeSpan duration, Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Returns

AcquireAsync(TimeSpan, RequestConditions, CancellationToken)

The AcquireAsync(TimeSpan, RequestConditions, CancellationToken) operation acquires a lease on the blob or container. The lease duration must be between 15 to 60 seconds, or infinite (-1).

If the container does not have an active lease, the Blob service creates a lease on the blob or container and returns it. If the container has an active lease, you can only request a new lease using the active lease ID as LeaseId, but you can specify a new duration.

For more information, see .

Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Storage.Blobs.Models.BlobLease>> AcquireAsync (TimeSpan duration, Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Returns

Break(Nullable<TimeSpan>, RequestConditions, CancellationToken)

The Break(Nullable<TimeSpan>, RequestConditions, CancellationToken) operation breaks the blob or container's previously-acquired lease (if it exists).

Once a lease is broken, it cannot be renewed. Any authorized request can break the lease; the request is not required to specify a matching lease ID. When a lease is broken, the lease break breakPeriod is allowed to elapse, during which time no lease operation except Break(Nullable<TimeSpan>, RequestConditions, CancellationToken) and Release(RequestConditions, CancellationToken) can be performed on the blob or container. When a lease is successfully broken, the response indicates the interval in seconds until a new lease can be acquired.

A lease that has been broken can also be released. A client can immediately acquire a blob or container lease that has been released.

For more information, see .

Declaration
public virtual Azure.Response<Azure.Storage.Blobs.Models.BlobLease> Break (Nullable<TimeSpan> breakPeriod = null, Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Nullable<TimeSpan> breakPeriod

Specifies the proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease will not be available before the break period has expired, but the lease may be held for longer than the break period. If this value is not provided, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks immediately.

Azure.RequestConditions conditions

Optional Azure.RequestConditions to add conditions on breaking a lease.

CancellationToken cancellationToken

Optional CancellationToken to propagate notifications that the operation should be cancelled.

Returns

BreakAsync(Nullable<TimeSpan>, RequestConditions, CancellationToken)

The BreakAsync(Nullable<TimeSpan>, RequestConditions, CancellationToken) operation breaks the blob or container's previously-acquired lease (if it exists).

Once a lease is broken, it cannot be renewed. Any authorized request can break the lease; the request is not required to specify a matching lease ID. When a lease is broken, the lease break breakPeriod is allowed to elapse, during which time no lease operation except BreakAsync(Nullable<TimeSpan>, RequestConditions, CancellationToken) and ReleaseAsync(RequestConditions, CancellationToken) can be performed on the blob or container. When a lease is successfully broken, the response indicates the interval in seconds until a new lease can be acquired.

A lease that has been broken can also be released. A client can immediately acquire a blob or container lease that has been released.

For more information, see .

Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Storage.Blobs.Models.BlobLease>> BreakAsync (Nullable<TimeSpan> breakPeriod = null, Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Nullable<TimeSpan> breakPeriod

Specifies the proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. This break period is only used if it is shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease will not be available before the break period has expired, but the lease may be held for longer than the break period. If this value is not provided, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks immediately.

Azure.RequestConditions conditions

Optional Azure.RequestConditions to add conditions on breaking a lease.

CancellationToken cancellationToken

Optional CancellationToken to propagate notifications that the operation should be cancelled.

Returns

Change(String, RequestConditions, CancellationToken)

Declaration
public virtual Azure.Response<Azure.Storage.Blobs.Models.BlobLease> Change (string proposedId, Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
String proposedId

An optional proposed lease ID, in a GUID string format. A RequestFailedException will be thrown if the proposed lease ID is not in the correct format.

Azure.RequestConditions conditions

Optional Azure.RequestConditions to add conditions on changing a lease.

CancellationToken cancellationToken

Optional CancellationToken to propagate notifications that the operation should be cancelled.

Returns

ChangeAsync(String, RequestConditions, CancellationToken)

Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Storage.Blobs.Models.BlobLease>> ChangeAsync (string proposedId, Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
String proposedId

An optional proposed lease ID, in a GUID string format. A RequestFailedException will be thrown if the proposed lease ID is not in the correct format.

Azure.RequestConditions conditions

Optional Azure.RequestConditions to add conditions on changing a lease.

CancellationToken cancellationToken

Optional CancellationToken to propagate notifications that the operation should be cancelled.

Returns

Release(RequestConditions, CancellationToken)

The Release(RequestConditions, CancellationToken) operation releases the container or blob's previously-acquired lease.

The lease may be released if the LeaseId matches that associated with the container or blob. Releasing the lease allows another client to immediately acquire the lease for the container or blob as soon as the release is complete.

For more information, see .

Declaration
public virtual Azure.Response<Azure.Storage.Blobs.Models.ReleasedObjectInfo> Release (Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.RequestConditions conditions

Optional Azure.RequestConditions to add conditions on releasing a lease.

CancellationToken cancellationToken

Optional CancellationToken to propagate notifications that the operation should be cancelled.

Returns

ReleaseAsync(RequestConditions, CancellationToken)

The ReleaseAsync(RequestConditions, CancellationToken) operation releases the container or blob's previously-acquired lease.

The lease may be released if the LeaseId matches that associated with the container or blob. Releasing the lease allows another client to immediately acquire the lease for the container or blob as soon as the release is complete.

For more information, see .

Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Storage.Blobs.Models.ReleasedObjectInfo>> ReleaseAsync (Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.RequestConditions conditions

Optional Azure.RequestConditions to add conditions on releasing a lease.

CancellationToken cancellationToken

Optional CancellationToken to propagate notifications that the operation should be cancelled.

Returns

ReleaseInternal(RequestConditions, Boolean, CancellationToken)

The ReleaseInternal(RequestConditions, Boolean, CancellationToken) operation releases the container or blob's previously-acquired lease.

The lease may be released if the LeaseId matches that associated with the container or blob. Releasing the lease allows another client to immediately acquire the lease for the container or blob as soon as the release is complete.

For more information, see .

Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Storage.Blobs.Models.ReleasedObjectInfo>> ReleaseInternal (Azure.RequestConditions conditions, bool async, System.Threading.CancellationToken cancellationToken);
Parameters
Azure.RequestConditions conditions

Optional Azure.RequestConditions to add conditions on releasing a lease.

Boolean async

Whether to invoke the operation asynchronously.

CancellationToken cancellationToken

Optional CancellationToken to propagate notifications that the operation should be cancelled.

Returns

Renew(RequestConditions, CancellationToken)

The Renew(RequestConditions, CancellationToken) operation renews the blob or container's previously-acquired lease.

The lease can be renewed if the leaseId matches that associated with the blob or container. Note that the] lease may be renewed even if it has expired as long as the blob or container has not been leased again since the expiration of that lease. When you renew a lease, the lease duration clock resets.

For more information, see .

Declaration
public virtual Azure.Response<Azure.Storage.Blobs.Models.BlobLease> Renew (Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.RequestConditions conditions

Optional Azure.RequestConditions to add conditions on renewing a lease.

CancellationToken cancellationToken

Optional CancellationToken to propagate notifications that the operation should be cancelled.

Returns

RenewAsync(RequestConditions, CancellationToken)

The RenewAsync(RequestConditions, CancellationToken) operation renews the blob or container's previously-acquired lease.

The lease can be renewed if the leaseId matches that associated with the blob or container. Note that the] lease may be renewed even if it has expired as long as the blob or container has not been leased again since the expiration of that lease. When you renew a lease, the lease duration clock resets.

For more information, see .

Declaration
[System.Diagnostics.DebuggerStepThrough] public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Storage.Blobs.Models.BlobLease>> RenewAsync (Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
Azure.RequestConditions conditions

Optional Azure.RequestConditions to add conditions on renewing a lease.

CancellationToken cancellationToken

Optional CancellationToken to propagate notifications that the operation should be cancelled.

Returns

ncG1vNJzZmiZqqq%2Fpr%2FDpJuom6Njr627wWeaqKqVY8SqusOorqxmnprBcHDWnplonJ%2Bpu6bAjnqxrqqVY6C1u9Ganp5mcqG8o7%2BOamlnaF5lfKK8yGh4s62imnuUwM6rmKCdXne5sK7SZ4qpnZOerq212Z6baHmqqr%2BmerKtpquZl5p7g7jOm6pni6CasKqty6Kxnpxed7mwrquemKydc6G2prrTZ5%2BtpZw%3D

Jenniffer Sheldon

Update: 2024-06-05