ShareLeaseClient.Acquire(Nullable<TimeSpan>, CancellationToken) Method

Definition

The Acquire(Nullable<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 Azure.Response<Azure.Storage.Files.Shares.Models.ShareFileLease> Acquire (TimeSpan? duration = default, System.Threading.CancellationToken cancellationToken = default);
abstract member Acquire : Nullable<TimeSpan> * System.Threading.CancellationToken -> Azure.Response<Azure.Storage.Files.Shares.Models.ShareFileLease>
override this.Acquire : Nullable<TimeSpan> * System.Threading.CancellationToken -> Azure.Response<Azure.Storage.Files.Shares.Models.ShareFileLease>
Public Overridable Function Acquire (Optional duration As Nullable(Of TimeSpan) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of ShareFileLease)

Parameters

duration
Nullable<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

A Response<T> describing the lease.

Remarks

A RequestFailedException will be thrown if a failure occurs.

Applies to