在 Azure 存储操作上设置超时
Set timeout on Azure Storage operations
在使用 Azure 存储时,如果您使用的是 REST,我看到有一种方法可以设置 timeout on blob operations and on table operations。
但是我们正在使用通过 WindowsAzure.Storage NuGet 包 (v8.4.0) 提供的 C# 客户端。我在这里看不到任何指定超时的方法
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");
我已经尝试在 CloudBlobClient
和 StorageAccount
上查看可用的 properties/methods,但没有找到任何类似于超时设置的内容。
如果我可以在一个地方(在连接字符串中??)设置超时并在所有操作中使用,那就太理想了。但我如何在 C# 客户端中执行此操作?
请看一下 ServerTimeout
property in BlobRequestOptions
class.So 您的代码将是:
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)
});
在使用 Azure 存储时,如果您使用的是 REST,我看到有一种方法可以设置 timeout on blob operations and on table operations。
但是我们正在使用通过 WindowsAzure.Storage NuGet 包 (v8.4.0) 提供的 C# 客户端。我在这里看不到任何指定超时的方法
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");
我已经尝试在 CloudBlobClient
和 StorageAccount
上查看可用的 properties/methods,但没有找到任何类似于超时设置的内容。
如果我可以在一个地方(在连接字符串中??)设置超时并在所有操作中使用,那就太理想了。但我如何在 C# 客户端中执行此操作?
请看一下 ServerTimeout
property in BlobRequestOptions
class.So 您的代码将是:
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)
});