Share via


StorageExtensions.CreateServiceTimeoutScope(Nullable<TimeSpan>) Method

Definition

Allows you to specify a server timeout for any Storage operations executing on this thread for the duration of the scope.

For more information, see Setting timeouts for Blob service operations, Setting timeouts for File service operations, Setting timeouts for Queue service operations.

public static IDisposable CreateServiceTimeoutScope (TimeSpan? timeout);
static member CreateServiceTimeoutScope : Nullable<TimeSpan> -> IDisposable
Public Shared Function CreateServiceTimeoutScope (timeout As Nullable(Of TimeSpan)) As IDisposable

Parameters

timeout
Nullable<TimeSpan>

The server timeout for each HTTP request.

Returns

The IDisposable instance that needs to be disposed when server timeout shouldn't be used anymore.

Examples

Sample usage:

BlobServiceClient client = new BlobServiceClient(connectionString, options);
using (StorageExtensions.CreateServiceTimeoutScope(TimeSpan.FromSeconds(10)))
{
    client.GetProperties();
}

Remarks

The server timeout is sent to the Azure Storage service for each REST request made within the scope. This value is not tracked or validated on the client, it is only passed to the Storage service.

Consider passing a CancellationToken to client methods and properly sizing NetworkTimeout when configuring storage clients as prefered way of enforcing upper boundary of execution time.

Applies to