ShareLeaseClient.AcquireAsync Method

Definition

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

cancellationToken
CancellationToken

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

Returns

A Response<T> describing the lease.

Remarks

A RequestFailedException will be thrown if a failure occurs.

Applies to