【问题标题】:azcopy (using sas-generator) giving 403 not authorized errorazcopy(使用 sas-generator)给出 403 not authorized 错误
【发布时间】:2022-02-17 16:26:56
【问题描述】:

我正在使用这个命令来生成 SAS,

az storage container generate-sas --account-name mystorageaccount --as-user --auth-mode login 
--expiry 2022-02-17T08:19Z --name container1 --permissions dlrw

但是。当我尝试使用 azcopy 复制我的容器时,它说我没有权限。

azcopy cp "https://[srcaccount].blob.core.windows.net?[SAS]" "https://[destaccount].blob.core.windows.net?[SAS]"
 --recursive

错误:

RESPONSE Status: 403 This request is not authorized to perform this operation using this permission.

   Content-Length: [279]
   Content-Type: [application/xml]
   Date: [Thu, 17 Feb 2022 05:21:16 GMT]
   Server: [Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0]
   X-Ms-Client-Request-Id: [xxx-xx-x-x-x-xx]
   X-Ms-Error-Code: [AuthorizationPermissionMismatch]
   X-Ms-Request-Id: [xx-x-x-x-x-xx]
   X-Ms-Version: [2019-12-12]

但是当我通过 GUI 为我的 azure 存储帐户容器生成 SAS 时,我使用容器检查允许的资源,然后它就可以工作了。

SAS GUI Example 如何通过 az 客户端允许资源?有人可以帮我解决这个问题吗?

编辑

所以我正在生成两个 SAS。 第一个用于: storageaccount => 'storageaccount1' 和 container => '/Container1'。 (换句话说,源容器,它给出了 SAS1)

第二个用于:storageaccount => 'storageaccount1' 和 container => '/Container2'。 (换句话说,目标容器,它给出了 SAS2)

并在 azcopy 中使用这两个容器。

azcopy cp "https://<storage_account>.blob.core.windows.net/<Container1>/<folder2>?<SAS1>" "https://<storage_account>.blob.core.windows.net/<Container2>/<foldeer2>?<SAS2>" --recursive=true

【问题讨论】:

    标签: azure azcopy


    【解决方案1】:

    我相信您收到此错误的原因是因为您正在为容器生成 SAS 令牌(即创建 Service SAS),但使用它将所有 blob 容器从一个帐户复制到另一个帐户,这需要 Account SAS .

    请使用az storage account generate-sas 创建帐户 SAS,然后您应该不会收到错误消息。

    【讨论】:

    • 所以我正在生成两个 SAS。第一个用于: storageaccount => 'storageaccount1' 和 container => '/Container1'。 (换句话说,源容器,它给出 )第二个是用于:storageaccount => 'storageaccount1' 和 container => '/Container2'。 (换句话说,目标容器,它提供 )并在 azcopy 中使用这两个容器。 azcopy cp "https://&lt;storage_account&gt;.blob.core.windows.net/&lt;Container1&gt;/&lt;folder2&gt;?&lt;SAS1&gt;" "https://&lt;storage_account&gt;.blob.core.windows.net/&lt;Container2&gt;/&lt;foldeer2&gt;?&lt;SAS2&gt;" --recursive=true
    • 我已经编辑了我的基本问题
    • 我看到您正在使用基于 Azure AD 的登录来创建 SAS 令牌。您能否检查获取令牌以获取 SAS 令牌的用户是否对存储帐户/容器具有适当的权限(存储数据贡献者/所有者)?
    猜你喜欢
    • 2014-11-09
    • 2015-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多