Delen via


DataLakeLeaseClient.AcquireAsync Method

Definition

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

If the file system does not have an active lease, the Data Lake service creates a lease on the file system or path and returns it. If the file system 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.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Storage.Files.DataLake.Models.DataLakeLease>> AcquireAsync (TimeSpan duration, Azure.RequestConditions conditions = default, System.Threading.CancellationToken cancellationToken = default);
abstract member AcquireAsync : TimeSpan * Azure.RequestConditions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Storage.Files.DataLake.Models.DataLakeLease>>
override this.AcquireAsync : TimeSpan * Azure.RequestConditions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Storage.Files.DataLake.Models.DataLakeLease>>
Public Overridable Function AcquireAsync (duration As TimeSpan, Optional conditions As RequestConditions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of DataLakeLease))

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. A lease duration cannot be changed using RenewAsync(RequestConditions, CancellationToken) or ChangeAsync(String, RequestConditions, CancellationToken).

conditions
RequestConditions

Optional RequestConditions to add conditions on acquiring a lease.

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