我尝试在不同的Azure门户目录/子公司之间复制CloudBlockBlobs。因此,每个存储帐户都属于不同的目录/ susbdiary。
当我尝试复制blob时,我得到了404.
public class CopyBlobs
{
private readonly CloudBlobClient _destClient;
public CopyBlobs(ICloudBlobClientFactory cloudBlobClientFactory)
{
_destClient = cloudBlobClientFactory.CreateDestinationClient();
}
public async Task<List<CloudBlockBlob>> Process(CloudBlobDirectory blobDirectory, string blobStorageId)
{
var blobs = new List<CloudBlockBlob>();
var sourceBlobItems = blobDirectory.ListBlobs(true).OfType<CloudBlockBlob>().ToList();
var destinationContainer = _destClient.GetContainerReference(blobStorageId);
await destinationContainer.CreateIfNotExistsAsync();
foreach (var sourceBlobItem in sourceBlobItems)
{
var exists = await sourceBlobItem.ExistsAsync(); // true
var destinationBlobItem = destinationContainer.GetBlockBlobReference(sourceBlobItem.Name);
var b = await destinationBlobItem.ExistsAsync(); // false
await destinationBlobItem.StartCopyAsync(sourceBlobItem.Uri); // 404
blobs.Add(destinationBlobItem);
}
return blobs;
}
}
我做错了吗?
是否可以在不同的Azure门户目录之间复制Azure CloudBlockBlobs?