【发布时间】:2015-07-16 14:22:06
【问题描述】:
我正在创建一个控制台应用程序,它将所有容器中的所有 blob 从我们用于生产的帐户复制到我们用于开发的另一个帐户。我有以下方法可以做到这一点。 “productionStorage”和“developmentStorage”对象位于另一个包含 Azure 存储客户端方法的程序集中。
static void CopyBlobsToDevelopment()
{
// Get a list of containers in production
List<CloudBlobContainer> productionBlobContainers = productionStorage.GetContainerList();
// For each container in production...
foreach (var productionContainer in productionBlobContainers)
{
// Get a list of blobs in the production container
var blobList = productionStorage.GetBlobList(productionContainer.Name);
// Need a referencee to the development container
var developmentContainer = developmentStorage.GetContainer(productionContainer.Name);
// For each blob in the production container...
foreach (var blob in blobList)
{
CloudBlockBlob targetBlob = developmentContainer.GetBlockBlobReference(blob.Name);
targetBlob.StartCopyFromBlob(new Uri(blob.Uri.AbsoluteUri));
}
}
}
我在targetBlob.StartCopyFromBlob() 行收到错误 (404)。但我不明白为什么会收到 404 错误。该 blob 确实存在于源(生产)中,我想将其复制到目标(开发)。不知道我做错了什么。
【问题讨论】:
-
请确保源 blob 容器上的 ACL 不是私有的。 HTH。
-
@GauravMantri - 谢谢。它是私人的。那么我需要在 StartCopyFromBlob 调用中提供凭据吗?
标签: azure azure-storage azure-blob-storage