gpt4 book ai didi

azure - startCopyFromBlob 操作卡在 0 进度

转载 作者:行者123 更新时间:2023-12-03 04:34:49 24 4
gpt4 key购买 nike

我正在尝试将页面 blob 从一个存储帐户复制到另一个存储帐户。复制操作开始,我在目标存储帐户中看到 blob - 但进度始终停留在 0。我正在使用 java SDK 并为源生成 SAS。 SAS 显示有效,因为我能够从浏览器下载 src blob。这是我正在使用的一些示例代码

    CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
CloudBlobClient strClient = account.createCloudBlobClient();
CloudBlobContainer strBlobContainer = strClient.getContainerReference("data");

CloudStorageAccount backupAccount = CloudStorageAccount.parse(backupStorageConnectionString);
CloudBlobClient backupClient = backupAccount.createCloudBlobClient();
CloudBlobContainer backupBlobContainer = backupClient.getContainerReference("data");


String src = "SG-aztest10-703-disk-0-test.vhd";
String target = "Tool-test4.vhd";
com.microsoft.azure.storage.blob.CloudPageBlob srcBlob = strBlobContainer.getPageBlobReference(src, null);
com.microsoft.azure.storage.blob.CloudPageBlob dstBlob = backupBlobContainer.getPageBlobReference(target, null);

System.out.println("Copying src blob " + " over dst blob " + dstBlob.getUri());
String copyID = dstBlob.startCopyFromBlob(new URI(getSharedAccessURI(src, null, strBlobContainer)));
System.out.println("Copy ID is " + copyID);

dstBlob.downloadAttributes();
CopyState state = dstBlob.getProperties().getCopyState();
while(state.getStatus().equals(CopyStatus.PENDING))
{
System.out.println("Progress is " + state.getBytesCopied()/state.getTotalBytes());
Thread.sleep(30000);

dstBlob.downloadAttributes();
state = dstBlob.getProperties().getCopyState();
}

这是我用来生成 SAS token 的代码

public static String getSharedAccessURI(String blobName,String snapshotID,CloudBlobContainer 容器)抛出异常 { //获取没有快照的srcBlob CloudPageBlob srcBlob = container.getPageBlobReference(blobName); SharedAccessBlobPolicy sasPolicy = new SharedAccessBlobPolicy();

    //Start Time = Current Time (UTC) - 15 minutes to account for Clock Skew
//Expiry Time = Current Time (UTC) + 1 day
sasPolicy.setPermissions(EnumSet.of(SharedAccessBlobPermissions.READ));
sasPolicy.setSharedAccessStartTime(DateTime.now().minusMinutes(15).toDate());
sasPolicy.setSharedAccessExpiryTime(DateTime.now().plusDays(1).toDate());
String sasToken = srcBlob.generateSharedAccessSignature(sasPolicy, null);

String sasURI = null;
if (snapshotID != null)
{
sasURI = String.format("%s?snapshot=%s&%s", srcBlob.getUri().toString(), snapshotID, sasToken);
}
else
{
sasURI = String.format("%s?%s", srcBlob.getUri().toString(), sasToken);
}
System.out.println("Shared access url is - " + sasURI);
return sasURI;
}

最佳答案

我们使用空闲带宽来执行异步复制,因此在带宽可用之前复制可能不会开始。在这种情况下,复制进度字段可能会在相当长的一段时间内保持为 0,而复制状态为挂起。如果 Blob 很小,进度字段可能会从 0 一次性完成,因为副本非常快。即使 blob 很大,您的轮询也可能会错过复制进度在 0 和内容长度之间的窗口。

关于azure - startCopyFromBlob 操作卡在 0 进度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28134708/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com