Class ShareLeaseClient
- Namespace
- Azure.Storage.Files.Shares.Specialized
- Assembly
- Azure.Storage.Files.Shares.dll
The ShareLeaseClient allows you to manipulate Azure Storage leases on files.
public class ShareLeaseClient
- Inheritance
-
ShareLeaseClient
- Inherited Members
Constructors
ShareLeaseClient()
Initializes a new instance of the ShareLeaseClient class for mocking.
protected ShareLeaseClient()
ShareLeaseClient(ShareClient, string)
Initializes a new instance of the ShareLeaseClient class.
public ShareLeaseClient(ShareClient client, string leaseId = null)
Parameters
client
ShareClientA ShareClient representing the share being leased.
leaseId
stringAn optional lease ID. If no lease ID is provided, a random lease ID will be created.
ShareLeaseClient(ShareFileClient, string)
Initializes a new instance of the ShareLeaseClient class.
public ShareLeaseClient(ShareFileClient client, string leaseId = null)
Parameters
client
ShareFileClientA ShareFileClient representing the file being leased.
leaseId
stringAn 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.
public static readonly TimeSpan InfiniteLeaseDuration
Field Value
Properties
FileClient
The ShareFileClient to manage leases for.
protected virtual ShareFileClient FileClient { get; }
Property Value
LeaseId
Gets the Lease ID for this lease.
public virtual string LeaseId { get; }
Property Value
ShareClient
The ShareClient to manage leases for.
protected virtual ShareClient ShareClient { get; }
Property Value
Uri
Gets the URI of the object being leased.
public Uri Uri { get; }
Property Value
- Uri
Methods
Acquire(TimeSpan?, CancellationToken)
The Acquire(TimeSpan?, CancellationToken) operation acquires a lease on the file.
If the file does not have an active lease, the File service creates a lease on the file and returns it. If the file has an active lease, you can only request a new lease using the active lease ID as LeaseId
public virtual Response<ShareFileLease> Acquire(TimeSpan? duration = null, CancellationToken cancellationToken = default)
Parameters
duration
TimeSpan?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. Files only support infinite lease. A lease duration cannot be changed using RenewAsync(CancellationToken) or ChangeAsync(string, CancellationToken).
Optional CancellationToken to propagate notifications that the operation should be cancelled.cancellationToken
CancellationToken
Returns
- Response<ShareFileLease>
A Azure.Response<> describing the lease.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
AcquireAsync(TimeSpan?, CancellationToken)
The AcquireAsync(TimeSpan?, CancellationToken) operation acquires a lease on the file.
If the file does not have an active lease, the File service creates a lease on the file and returns it. If the file has an active lease, you can only request a new lease using the active lease ID as LeaseId.
public virtual Task<Response<ShareFileLease>> AcquireAsync(TimeSpan? duration = null, CancellationToken cancellationToken = default)
Parameters
duration
TimeSpan?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. Files only support infinite lease. A lease duration cannot be changed using RenewAsync(CancellationToken) or ChangeAsync(string, CancellationToken).
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileLease>>
A Azure.Response<> describing the lease.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
Break(CancellationToken)
The Break(CancellationToken) operation breaks the files'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.
A lease that has been broken can also be released. A client can immediately acquire a file lease that has been released.
public virtual Response<ShareFileLease> Break(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileLease>
A Azure.Response<> describing the broken lease.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
BreakAsync(CancellationToken)
The BreakAsync(CancellationToken) operation breaks the files'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.
A lease that has been broken can also be released. A client can immediately acquire a file lease that has been released.
public virtual Task<Response<ShareFileLease>> BreakAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileLease>>
A Azure.Response<> describing the broken lease.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
Change(string, CancellationToken)
The Change(string, CancellationToken) operation changes the lease
of an active lease. A change must include the current
LeaseId and a new proposedId
.
public virtual Response<ShareFileLease> Change(string proposedId, CancellationToken cancellationToken = default)
Parameters
proposedId
stringAn 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.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileLease>
A Azure.Response<> describing the lease.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
ChangeAsync(string, CancellationToken)
The ChangeAsync(string, CancellationToken) operation changes the lease
of an active lease. A change must include the current
LeaseId and a new proposedId
.
public virtual Task<Response<ShareFileLease>> ChangeAsync(string proposedId, CancellationToken cancellationToken = default)
Parameters
proposedId
stringAn 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.
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileLease>>
A Azure.Response<> describing the lease.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
Release(CancellationToken)
The Release(CancellationToken) operation releases the files's previously-acquired lease.
The lease may be released if the LeaseId matches that associated with the file. Releasing the lease allows another client to immediately acquire the lease for the file as soon as the release is complete.
public virtual Response<FileLeaseReleaseInfo> Release(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<FileLeaseReleaseInfo>
A Azure.Response<> describing the updated blob or container.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
ReleaseAsync(CancellationToken)
The ReleaseAsync(CancellationToken) operation releases the files's previously-acquired lease.
The lease may be released if the LeaseId matches that associated with the file. Releasing the lease allows another client to immediately acquire the lease for the file as soon as the release is complete.
public virtual Task<Response<FileLeaseReleaseInfo>> ReleaseAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<FileLeaseReleaseInfo>>
A Azure.Response<> describing the updated file.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
Renew(CancellationToken)
The Renew(CancellationToken) operation renews the shares's previously-acquired lease. This API does not support files.
The lease can be renewed if the leaseId matches that associated with the share. Note that the lease may be renewed even if it has expired as long as the share has not been leased again since the expiration of that lease. When you renew a lease, the lease duration clock resets.
public virtual Response<ShareFileLease> Renew(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Response<ShareFileLease>
A Azure.Response<> describing the lease.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.
RenewAsync(CancellationToken)
The RenewAsync(CancellationToken) operation renews the shares's previously-acquired lease. This API does not support files.
The lease can be renewed if the leaseId matches that associated with the share. Note that the lease may be renewed even if it has expired as long as the share has not been leased again since the expiration of that lease. When you renew a lease, the lease duration clock resets.
public virtual Task<Response<ShareFileLease>> RenewAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenOptional CancellationToken to propagate notifications that the operation should be cancelled.
Returns
- Task<Response<ShareFileLease>>
A Azure.Response<> describing the lease.
Remarks
A Azure.RequestFailedException will be thrown if a failure occurs.