中断从 Azure Blob 存储的传输

Interrupting a transfer from Azure Blob storage

我有相当大的文件要从 blob 存储中检索,我正在考虑恢复能力。如果下载失败,例如网络连接暂时中断,需要重试 x 次。但是我注意到我不知道如何处理的行为。

我正在通过简单地在传输到我的机器的过程中拔掉我的网络电缆来复制网络故障。然后发生的是传输停止在 x% 并且永远不会继续。会话保持活动状态,传输任务仍处于打开状态并且目标文件保持锁定状态。即使在我重新插入电缆后,它也会保持这种状态,直到我关闭我的 PowerShell 会话(在本例中为 ISE)。

这是我正在使用的命令:

Get-AzureStorageBlobContent -blob $file.Name -Container $containerName -Destination $localPath -Context $Context -clientTimeoutPerRequest 60  -ErrorAction Stop -Force 

它从不抛出错误,只是卡住了。无论如何我可以让它超时并且 return 抛出一个错误到 catch 块?

It never throws an error, it just gets stuck. Is there anyway I can get this to timeout and return an error to throw to a catch block?

正如您所说,如果在通过 Get-AzureStorageBlobContent cmdlet 下载 blob 期间网络问题导致中断,错误将不会到达 catch 块。如果你想重新开始传输,让传输从中断点开始,你可以尝试使用AZCopy。并且支持AZCopy with in re-startable 模式,用于在文件传输过程中因网络或其他问题导致的中断,这有助于从中断点重新启动传输。