我使用DataMovement库将文件上传到Azure存储帐户。blob大小为96 is。
如果每次连接速度较慢,则在15分钟后上传失败,出现错误:,一个或多个错误。(传输失败)
我的代码:
CloudBlockBlob blockBlob = new CloudBlockBlob(new Uri(sConnString));
ServicePointManager.Expect100Continue = false;
TransferManager.Configurations.ParallelOperations = 10;
...
var task = TransferManager.UploadAsync(pathFile, blockBlob, null, context, CancellationToken.None);
task.Wait();我该怎么解决呢?为什么15分钟?
错误StackTrace:
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at TeamSystem.Enterprise.Cloud.Migrator.Engine.CloudServices.UploadFile(String pathFile, String blobName, Boolean testMode) in C:\EnterpriseCloud\Migrator\TeamSystem.Enterprise.Cloud.Migrator.Engine\Code\CloudServices.cs:line 86非常感谢。
发布于 2019-07-12 14:00:11
我找到解决办法了!问题出在"TransferManager.Configurations.ParallelOperations“属性上。
如果连接缓慢,尝试将该值从64降到2,我没有这个问题。
因此,我从连接速度为"ParallelOperations“创建了这样一个函数:
private int GetParallelOperations(double transfertSpeed)
{
int retval = 0;
switch (transfertSpeed)
{
case double n when (n >= 1):
retval = Environment.ProcessorCount * 8;
break;
case double n when (n < 1 && n>=0.1):
retval = 10;
break;
default:
retval = 2;
break;
}
return retval;
}然后:
TransferManager.Configurations.ParallelOperations = GetParallelOperations(Utilities.TransferSpeed);其中传输速度被一个大小为5MB的简单文件所抑制。对于速度测试,我将"ParallelOperations“设置为"Environment.ProcessorCount * 8”(在连接缓慢的情况下也有效)。
https://stackoverflow.com/questions/56973598
复制相似问题