Class BlobLeaseClient
The BlobLeaseClient allows you to manipulate Azure Storage leases on containers and blobs.
Inheritance
Namespace: System.Dynamic.ExpandoObject
Assembly: Azure.Storage.Blobs.dll
Syntax
public class BlobLeaseClient
Constructors
BlobLeaseClient()
Initializes a new instance of the BlobLeaseClient class for mocking.
Declaration
protected BlobLeaseClient ();
BlobLeaseClient(BlobContainerClient, String)
Initializes a new instance of the BlobLeaseClient class.
Declaration
public BlobLeaseClient (Azure.Storage.Blobs.BlobContainerClient client, string leaseId = null);
Parameters
BlobContainerClient
client
A BlobContainerClient representing the blob container being leased. |
System.String
leaseId
An optional lease ID. If no lease ID is provided, a random lease ID will be created. |
BlobLeaseClient(BlobBaseClient, String)
Initializes a new instance of the BlobLeaseClient class.
Declaration
public BlobLeaseClient (Azure.Storage.Blobs.Specialized.BlobBaseClient client, string leaseId = null);
Parameters
BlobBaseClient
client
A BlobClient representing the blob being leased. |
System.String
leaseId
An optional lease ID. If no lease ID is provided, a random lease ID will be created. |
Fields
InfiniteLeaseDuration
The System.TimeSpan representing an infinite lease duration.
Declaration
public static readonly TimeSpan InfiniteLeaseDuration;
Field Value
System.TimeSpan
|
Properties
BlobClient
Gets the BlobClient to manage leases for.
Declaration
protected virtual Azure.Storage.Blobs.Specialized.BlobBaseClient BlobClient { get; }
Property Value
BlobBaseClient
|
BlobContainerClient
Gets the BlobContainerClient to manage leases for.
Declaration
protected virtual Azure.Storage.Blobs.BlobContainerClient BlobContainerClient { get; }
Property Value
BlobContainerClient
|
LeaseId
Gets the Lease ID for this lease.
Declaration
public string LeaseId { get; }
Property Value
System.String
|
Uri
Gets the URI of the object being leased.
Declaration
public Uri Uri { get; }
Property Value
System.Uri
|
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
.
Declaration
public virtual Azure.Response<Azure.Storage.Blobs.Models.BlobLease> Acquire (TimeSpan duration, Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
System.TimeSpan
duration
Specifies the duration of the lease, in seconds, or specify InfiniteLeaseDuration for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using RenewAsync(RequestConditions, CancellationToken) or ChangeAsync(String, RequestConditions, CancellationToken). |
Azure.RequestConditions
conditions
Optional BlobLeaseRequestConditions to add conditions on acquiring a lease. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
Azure.Response<BlobLease>
A Azure.Response describing the lease. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
AcquireAsync(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 Lease Container.
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
System.TimeSpan
duration
Specifies the duration of the lease, in seconds, or specify InfiniteLeaseDuration for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using RenewAsync(RequestConditions, CancellationToken) or ChangeAsync(String, RequestConditions, CancellationToken). |
Azure.RequestConditions
conditions
Optional BlobLeaseRequestConditions to add conditions on acquiring a lease. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
System.Threading.Tasks.Task<Azure.Response<BlobLease>>
A Azure.Response describing the lease. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
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 Lease Container.
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
System.Nullable<System.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 BlobLeaseRequestConditions to add conditions on breaking a lease. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
Azure.Response<BlobLease>
A Azure.Response describing the broken lease. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
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 Lease Container.
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
System.Nullable<System.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 BlobLeaseRequestConditions to add conditions on breaking a lease. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
System.Threading.Tasks.Task<Azure.Response<BlobLease>>
A Azure.Response describing the broken lease. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
Change(String, RequestConditions, CancellationToken)
The Change(String, RequestConditions, CancellationToken) operation changes the lease
of an active lease. A change must include the current
LeaseId and a new proposedId
.
For more information, see Lease Container.
Declaration
public virtual Azure.Response<Azure.Storage.Blobs.Models.BlobLease> Change (string proposedId, Azure.RequestConditions conditions = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
System.String
proposedId
An optional proposed lease ID, in a GUID string format. A Azure.RequestFailedException will be thrown if the proposed lease ID is not in the correct format. |
Azure.RequestConditions
conditions
Optional BlobLeaseRequestConditions to add conditions on changing a lease. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
Azure.Response<BlobLease>
A Azure.Response describing the lease. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
ChangeAsync(String, RequestConditions, CancellationToken)
The ChangeAsync(String, RequestConditions, CancellationToken) operation changes the lease
of an active lease. A change must include the current
LeaseId and a new proposedId
.
For more information, see Lease Container.
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
System.String
proposedId
An optional proposed lease ID, in a GUID string format. A Azure.RequestFailedException will be thrown if the proposed lease ID is not in the correct format. |
Azure.RequestConditions
conditions
Optional BlobLeaseRequestConditions to add conditions on changing a lease. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
System.Threading.Tasks.Task<Azure.Response<BlobLease>>
A Azure.Response describing the lease. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
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 Lease Container.
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 BlobLeaseRequestConditions to add conditions on releasing a lease. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
Azure.Response<ReleasedObjectInfo>
A Azure.Response describing the updated blob or container. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
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 Lease Container.
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 BlobLeaseRequestConditions to add conditions on releasing a lease. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
System.Threading.Tasks.Task<Azure.Response<ReleasedObjectInfo>>
A Azure.Response describing the updated blob or container. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
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 Lease Container.
Declaration
[System.ComponentModel.EditorBrowsable]
[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 BlobLeaseRequestConditions to add conditions on releasing a lease. |
System.Boolean
async
Whether to invoke the operation asynchronously. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
System.Threading.Tasks.Task<Azure.Response<ReleasedObjectInfo>>
A Azure.Response describing the updated blob or container. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
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 Lease Container.
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 BlobLeaseRequestConditions to add conditions on renewing a lease. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
Azure.Response<BlobLease>
A Azure.Response describing the lease. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
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 Lease Container.
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 BlobLeaseRequestConditions to add conditions on renewing a lease. |
System.Threading.CancellationToken
cancellationToken
Optional System.Threading.CancellationToken to propagate notifications that the operation should be cancelled. |
Returns
System.Threading.Tasks.Task<Azure.Response<BlobLease>>
A Azure.Response describing the lease. |
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.