Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set timeout on Azure Storage operations

When working with Azure Storage I see there is a way to set a timeout on blob operations and on table operations if you are working with REST.

However we are working with C# client provided via WindowsAzure.Storage NuGet package (v8.4.0). And I don't see any way to specify a timeout here

var storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1"); // local storage for testing
var blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("mycontainer");
container.CreateIfNotExists();
var blobReference = container.GetBlockBlobReference("my/blob.pdf");

I've tried what looking through available properties/methods on CloudBlobClient and on StorageAccount, but did not find anything resembling timeout setting.

It would be ideal if I can set timout in one place (in connection string??) and that is used in all the operations. But how do I do this in C# client?

like image 515
trailmax Avatar asked Feb 09 '18 16:02

trailmax


People also ask

What is maximum timeout interval for Azure storage queue service operations?

The maximum timeout interval for Queue service operations is 30 seconds. The Queue service automatically reduces any timeouts larger than 30 seconds to the 30-second maximum.

What is write operations in Azure storage?

The following API calls are considered Write Operations: PutBlob, PutBlock, PutBlockList, AppendBlock, SnapshotBlob, CopyBlob and SetBlobTier (when it moves a Blob from Hot to Cool, Cool to Archive or Hot to Archive).

How do I restrict access to storage on Azure?

1. From the Azure portal, browse to storage account->Settings->Firewalls and virtual networks. By default, access will be set to “All networks.” Change this setting to “Selected networks” and click on “Add existing virtual network” to restrict access to Azure endpoints.

What is BlobServiceClient?

The BlobServiceClient allows you to manipulate Azure Storage service resources and blob containers. The storage account provides the top-level namespace for the Blob service.


1 Answers

Do take a look at ServerTimeout property in BlobRequestOptions class.So your code would be:

            var storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1"); // local storage for testing
            var blobClient = storageAccount.CreateCloudBlobClient();
            var container = blobClient.GetContainerReference("mycontainer");
            container.CreateIfNotExists(new BlobRequestOptions()
            {
                ServerTimeout = TimeSpan.FromSeconds(90)
            });
like image 100
Gaurav Mantri Avatar answered Sep 24 '22 23:09

Gaurav Mantri