tra*_*max 2 c# azure azure-storage azure-table-storage azure-blob-storage
使用Azure存储时,我发现如果您使用REST,有一种方法可以在blob操作和表操作上设置超时.
但是我们正在使用通过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");
Run Code Online (Sandbox Code Playgroud)
我已经尝试了查看可用属性/方法的CloudBlobClient内容StorageAccount,但没有找到类似超时设置的内容.
如果我可以在一个地方设置timout(在连接字符串中)并且在所有操作中使用它,那将是理想的.但是我如何在C#客户端中执行此操作?
请看看课堂上的ServerTimeout财产.BlobRequestOptions所以你的代码是:
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)
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2092 次 |
| 最近记录: |