相关疑难解决方法(0)

通过慢速网络下载大型文件时出现StorageException

我正在使用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)

c# exception azure azure-storage azure-storage-blobs

3
推荐指数
1
解决办法
3827
查看次数