我正在使用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);
}
Run Code Online (Sandbox Code Playgroud)
但是,有时它下载约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) …
Run Code Online (Sandbox Code Playgroud)