如何将 Azure 管道中的 Azure 文件复制授予访问 Azure 存储的权限?

3

我想使用Azure管道中的Azure文件复制来复制文件。

我正在按照https://praveenkumarsreeram.com/2021/04/14/azure-devops-copy-files-from-git-repository-to-azure-storage-account/的指示进行操作。

我正在使用自动创建的名为“我的沙盒(a1111e1-d30e-4e02-b047-ef6a5e901111)”的服务连接。

我在使用AzureBlob文件复制时遇到了错误:

 INFO: Authentication failed, it is either not correct, or 
 expired, or does not have the correct permission -> 
 github.com/Azure/azure-storage-blob-go/azblob.newStorageError, 
 /home/vsts/go/pkg/mod/github.com/!azure/azure-storage-blob- 
 go@v0.10.1-0.20201022074806- 
 8d8fc11be726/azblob/zc_storage_error.go:42

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

我假设Azure Pipeline无法访问Azure Storage。 我想知道如何找到应该访问Azure Storage的服务主体。


博客作者在使用 Azure 文件复制任务版本 4.* 时遇到了相同的错误,但在版本 3.* 中可以正常工作,你试过那个版本吗? - Joy Wang
1个回答

11
我也能在我的电脑上重现您的问题,因为不同的Azure文件复制任务版本使用不同版本的AzCopy,然后它们使用不同的身份验证方式调用API来执行操作。
有两种方法可以解决这个问题:
1. 如果您使用自动创建的服务连接,则它应该在您的存储账户中具有Contributor角色。您可以使用Azure文件复制任务版本3.*代替4.*,那么它就能正常工作。
2. 如果您想使用Azure文件复制任务版本4.*,则需要导航到您的存储账户->访问控制(IAM)->添加您在服务连接中使用的服务主体,作为Storage Blob Data Contributor角色,请参考此处详细步骤。这样也能使它正常工作。

谢谢,它起作用了。这非常容易出错。你知道他们为什么在v4中做出这个改变吗?v3似乎更合理。 - lty

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接