本文介绍了如何复制Azure的容器及放大器;斑点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试所有的斑点复制到不同的存储:

  CloudBlobClient srcblobClient = sourceStorageAccount.CreateCloudBlobClient();
CloudBlobClient targetBlobClient = targetStorageAccount.CreateCloudBlobClient();的foreach(在srcblobClient.ListContainers CloudBlobContainer续())
{
    的foreach(IListBlobItem srcBlob在cont.ListBlobs(useFlatBlobListing:真))
    {
        VAR targetContainer = targetBlobClient.GetContainerReference(cont.Name);
        targetContainer.CreateIfNotExists();        乌里thisBlobUri = srcBlob.Uri;
        VAR serverBlob = srcblobClient.GetBlobReferenceFromServer(thisBlobUri);        ICloudBlob targetBlob = targetContainer.GetBlobReferenceFromServer(serverBlob.Name);        targetBlob.StartCopyFromBlob(thisBlobUri);
    }
}

我能看到的斑点和放大器的上市;被调用的复制方法 targetBlob.StartCopyFromBlob(thisBlobUri);

不过副本不会实际发生。任何想法?

P.S。我使用Azure存储SDK 4.3&安培;目标存储是存储发展

编辑2:

有关上述code远程Azure存储复制正常工作。

My emulated storage version is 3.0, it seems there is conflict between azure SDK & emulator version.

解决方案

The reason you're getting this error is indeed because of version mismatch. If I am not mistaken, Storage Emulator version 3.0 uses REST API version 2013-08-15 where as the latest version of storage client library uses REST API version 2014-02-14 (Ref: http://msdn.microsoft.com/en-us/library/azure/dn744252.aspx). What you could is make use of an older version of storage client library. You can install appropriate version via Nuget. For example, if you want to install Storage Client Library version 3.2.1, you can do so by doing the following:

Please try it out and see if that fixes the problem.

Also looking at your code, I would also recommend some changes:

  • I would not recommend changing the permission on Blob Container to Public. It kind of exposes your blob storage and makes it available via anonymous access. What I would recommend is that you create SAS URLs with Read Permission on your source blobs and copy using those SAS URLs. Since the blob copy is asynchronous, I would recommend keeping the SAS URL valid for 7 days (maximum time allocated for copy operation).
  • I see that you're doing GetBlobReferenceFromServer on both source blob and target blob. This method is not recommended for source blob as it actually makes a network call thus for each blob you already got through listing. It is not recommended on target blob because this method will throw a Not Found (404) if your target blob does not exist.

Instead what I would recommend is that you cast the blobs you got through listing into appropriate blob type (Block or Page) and then get SAS URL. If you know that all of your blobs are block blobs, you can simply cast them into CloudBlockBlob object without worrying about the casting.

One thing I am not sure of is how page blobs will get copied. When you're copying between storage accounts, a page blob gets copied as a page blob. However I have not tried copying from a storage account to development storage account. But if you don't have page blobs, you don't have to worry about it :).

这篇关于如何复制Azure的容器及放大器;斑点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 13:05
查看更多