【发布时间】:2019-11-04 13:21:41
【问题描述】:
我遇到了Microsoft.WindowsAzure.Storage v9.3.3 和Microsoft.Azure.Storage.Blob v11.1.0 NuGet 库的问题。特别是在下载大文件时。如果您在“DownloadToStreamAsync”方法期间更改网络,呼叫将挂起。我一直看到我的代码处理大量文件,它偶尔会挂起,我一直在尝试缩小范围。我认为网络更改可能是触发 Azure Blob 存储库中某些故障的可靠方式。
有关该问题的更多信息;
- 当我拔下网线时,我的计算机切换到 WiFi,但请求永远不会恢复
- 如果我在 WiFi 上开始下载,然后插入我的网线,则会出现同样的错误
- “ServerTimeout”属性永远不会使请求失败或按照Documentation 的预期运行
- “MaximumExecutionTime”属性确实使请求失败,但我们不想将自己限制在某个时间段内,尤其是因为我们正在处理大文件
如果在调用过程中更改了网络,则以下代码 100% 会失败。
static void Main(string[] args)
{
try
{
CloudStorageAccount.TryParse("<Connection String>", out var storageAccount);
var cloudBlobClient = storageAccount.CreateCloudBlobClient();
var container = cloudBlobClient.GetContainerReference("<Container Reference>");
var blobRef = container.GetBlockBlobReference("Large Text.txt");
Stream memoryStream = new MemoryStream();
BlobRequestOptions optionsWithRetryPolicy = new BlobRequestOptions() { ServerTimeout = TimeSpan.FromSeconds(5), RetryPolicy = new LinearRetry(TimeSpan.FromSeconds(20), 4) };
blobRef.DownloadToStreamAsync(memoryStream, null, optionsWithRetryPolicy, null).GetAwaiter().GetResult();
Console.WriteLine("Completed");
}
catch (Exception ex)
{
Console.WriteLine($"Exception: {ex.Message}");
}
finally
{
Console.WriteLine("Finished");
}
}
我在 Azure 存储 GitHub 中找到了 this active issue,但它似乎处于非活动状态。
我可以采取任何其他方法来可靠有效地下载 blob 或我在使用此包时缺少的东西吗?
【问题讨论】:
-
那么你的问题是什么?
-
抱歉,我现在已经编辑了我的帖子。我想知道我还能做些什么吗?
标签: c# azure azure-blob-storage