StorageExtensions.CreateServiceTimeoutScope(Nullable<TimeSpan>) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
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
Azure SDK for .NET