【发布时间】:2015-09-16 16:49:51
【问题描述】:
我正在使用 NuGet 包WindowsAzure.Storage 4.2.1 版。
以下代码尝试从位于远程数据中心的存储容器下载 Blob。
try
{
var blobRequestOptions = new BlobRequestOptions
{
RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(5), 3),
MaximumExecutionTime = TimeSpan.FromMinutes(60),
ServerTimeout = TimeSpan.FromMinutes(60)
};
using (var fileStream = File.Create(localPath))
{
blockBlob.DownloadToStream(fileStream, null, blobRequestOptions);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
但是,有时它会下载约 10 分钟,然后引发以下异常:
Unhandled Exception: Microsoft.WindowsAzure.Storage.StorageException: The client could not finish the operation within specified timeout. ---> System.TimeoutException: The client could not finish the operation within specified timeout.
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.Storage.Core.Util.StorageAsyncResult`1.End()
at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.EndUploadText(IAsyncResult asyncResult)
at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass4.b__3(IAsyncResult ar)
--- End of stack trace from previous location where exception was thrown ---
我该如何解决这个问题?
【问题讨论】:
-
blob 有多大?
-
@GauravMantri 大约 500 MB
-
谢谢。分块下载是一种选择吗?基本上,这个想法是您以较小的块下载这个大 blob,然后在下载块时构建文件。
-
是的,我想是的,如果可行的话:) 你能提供一个代码示例吗?
标签: c# exception azure azure-storage azure-blob-storage