使用AzCo​​py和共享访问键Azure的跨账户复印件 [英] Azure cross-account copy using AzCopy and Shared Access Key

查看:460
本文介绍了使用AzCo​​py和共享访问键Azure的跨账户复印件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用AzC​​o​​py复制BLOB从帐户A到账户B但不是使用源快捷键,我只能访问共享访问键。我试着在URL后追加SAS,但它抛出一个404错误。这是我试过的语法

I want to use AzCopy to copy a blob from account A to account B. But instead of using access key for the source, I only have access to the Shared Access Key. I've tried appending the SAS after the URL, but it throws a 404 error. This is the syntax I tried

AzCopy "https://source-blob-object-url?sv=blah-blah-blah-source-sas" "https://dest-blob-object-url" /destkey:base64-dest-access-key

我得到的错误是

Error parsing source location "https://source-blob-object-url?sv=blah-blah-blah-source-sas": 
The remote server returned an error: (404) Not Found.

我怎样才能得到AzCopy使用SAS网址?或者说,它不支持SAS?

How can I get AzCopy to use the SAS URL? Or that it doesn't support SAS?

更新:
随着SourceSAS和FilePattern选择,我仍然得到404错误。这是我使用的命令:

Update: With the SourceSAS and FilePattern options, I'm still getting the 404 error. This is the command I use:

AzCopy [source-container-url] [destination-container-url] [file-pattern] /SourceSAS:"?sv=2013-08-15&sr=c&si=ReadOnlyPolicy&sig=[signature-removed]" /DestKey:[destination-access-key]

这将让我一个404没有找到。如果我更改签名,使之无效,AzCopy将抛出一个403而不是禁止。

This will get me a 404 Not Found. If I change the signature to make it invalid, AzCopy will throw a 403 Forbidden instead.

推荐答案

你是正确的。当源和目的地的斑点在同一存储帐户只支持源和目标斑点使用SAS复制操作。跨使用SAS存储帐户复制仍然没有被Windows Azure存储支持。这已被覆盖(尽管班轮只)从存储团队这个博客帖子:<一href=\"http://blogs.msdn.com/b/windowsazurestorage/archive/2013/11/27/windows-azure-storage-release-introducing-cors-json-minute-metrics-and-more.aspx\" rel=\"nofollow\">http://blogs.msdn.com/b/windowsazurestorage/archive/2013/11/27/windows-azure-storage-release-introducing-cors-json-minute-metrics-and-more.aspx.从岗位:

You're correct. Copy operation using SAS on both source and destination blobs is only supported when source and destination blobs are in same storage account. Copying across storage accounts using SAS is still not supported by Windows Azure Storage. This has been covered (though one liner only) in this blog post from storage team: http://blogs.msdn.com/b/windowsazurestorage/archive/2013/11/27/windows-azure-storage-release-introducing-cors-json-minute-metrics-and-more.aspx. From the post:

复印斑点现在允许共享访问签名(SAS),以用于
  目的地BLOB如果复制的是同一个存储帐户中。

Copy blob now allows Shared Access Signature (SAS) to be used for the destination blob if the copy is within the same storage account.

更新

于是,我尝试过了,一件事,我意识到的是,它是为复制所有斑点从一个容器到另一个。根据我的试验/错误,你需要记住的几件事情是:

So I tried it and one thing I realized is that it is meant for copying all blobs from one container to another. Based on my trial/error, a few things you would need to keep in mind are:


  • 源SAS是源容器,而不是BLOB。还要确保既有的 列表 许可就在SAS的BLOB容器中。

  • 如果您要复制一个文件,请确保它被定义为filepattern参数。

根据这些,你可以请尝试以下方法:

Based on these, can you please try the following:

AzCopy "https://<source account>.blob.core.windows.net/<source container>?<source container sas with read/list permission>" "https://<destination account>.blob.core.windows.net/<destination container>" "<source blob name to copy>" /DestKey:"destination account key"

更新2

错误解析源位置[容器位置]:对象引用
  不设置为一个对象的一个​​实例。

Error parsing source location [container-location]: Object reference not set to an instance of an object.

我能够重现错误。我相信,此错误的原因是用于创建SAS存储令牌客户端库(因而REST API)的版本。如果我尝试使用列表中使用的库版本3.x创建的SAS令牌一个blob容器的内容,这是输出我得到:

I was able to recreate the error. I believe the reason for this error is the version of storage client library (and thus the REST API) which is used to create SAS token. If I try to list contents of a blob container using a SAS token created by using version 3.x of the library, this is the output I get:

<?xml version="1.0" encoding="utf-8"?>
<EnumerationResults ServiceEndpoint="https://cynapta.blob.core.windows.net/" ContainerName="vhds">
  <Blobs>
    <Blob>
      <Name>test.vhd</Name>
      <Properties>
        <Last-Modified>Fri, 17 May 2013 15:23:39 GMT</Last-Modified>
        <Etag>0x8D02129A4ACFFD7</Etag>
        <Content-Length>10486272</Content-Length>
        <Content-Type>application/octet-stream</Content-Type>
        <Content-Encoding />
        <Content-Language />
        <Content-MD5>uflK5qFmBmek/zyqad7/WQ==</Content-MD5>
        <Cache-Control />
        <Content-Disposition />
        <x-ms-blob-sequence-number>0</x-ms-blob-sequence-number>
        <BlobType>PageBlob</BlobType>
        <LeaseStatus>unlocked</LeaseStatus>
        <LeaseState>available</LeaseState>
      </Properties>
    </Blob>
  </Blobs>
  <NextMarker />
</EnumerationResults>

但是,如果我尝试使用列表中通过使用库2.x版创建的SAS令牌一个blob容器的内容,这是输出我得到:

However if I try to list contents of a blob container using a SAS token created by using version 2.x of the library, this is the output I get:

<?xml version="1.0" encoding="utf-8"?>
<EnumerationResults ContainerName="https://cynapta.blob.core.windows.net/vhds">
  <Blobs>
    <Blob>
      <Name>test.vhd</Name>
      <Url>https://cynapta.blob.core.windows.net/vhds/test.vhd</Url>
      <Properties>
        <Last-Modified>Fri, 17 May 2013 15:23:39 GMT</Last-Modified>
        <Etag>0x8D02129A4ACFFD7</Etag>
        <Content-Length>10486272</Content-Length>
        <Content-Type>application/octet-stream</Content-Type>
        <Content-Encoding />
        <Content-Language />
        <Content-MD5>uflK5qFmBmek/zyqad7/WQ==</Content-MD5>
        <Cache-Control />
        <x-ms-blob-sequence-number>0</x-ms-blob-sequence-number>
        <BlobType>PageBlob</BlobType>
        <LeaseStatus>unlocked</LeaseStatus>
        <LeaseState>available</LeaseState>
      </Properties>
    </Blob>
  </Blobs>
  <NextMarker />
</EnumerationResults>

注意在不同的&LT; EnumerationResults方式&gt; 的XElement

现在 AzCopy 使用版本2.1.0.4版本的存储客户端库。作为复制操作的一部分首先列出使用SAS令牌源容器中的斑点。现在,当我们返回的XML上面看到的是两个版本不同,因此存储客户端库2.1.0.4无法解析由存储服务返回的XML。因为它无法解析XML,它不能创建一个的Blob 对象,所以你获得的NullReferenceException

Now AzCopy uses version 2.1.0.4 version of the storage client library. As a part of copying operation it first lists the blobs in source container using the SAS token. Now as we saw above the XML returned is different in both versions so storage client library 2.1.0.4 fails to parse the XML returned by storage service. Because it fails to parse the XML, it is not able to create a Blob object and thus you get the NullReferenceException.

解决方案:

的一种可能的解决这个问题是使用的版本2.1.0.4版本的库来创建SAS令牌。我想这样做,并能够成功复制团块。不要试试看。这应该可以解决你面临的问题。

One possible solution to this problem is to create a SAS token using version 2.1.0.4 version of the library. I tried doing that and was able to successfully copy the blob. Do give it a try. That should fix the problem you're facing.

这篇关于使用AzCo​​py和共享访问键Azure的跨账户复印件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆