如何向 Azure 存储授予对 Azure Pipeline 的 Azure 文件副本的访问权限?

Ken*_*y_I 3 azure-storage azure-devops

我想通过 Azure Pipeline 使用 Azure 文件复制来复制文件。

我正在遵循https://praveenkumarsreeram.com/2021/04/14/azure-devops-copy-files-from-git-repository-to-azure-storage-account/的说明

我正在使用自动创建的名为“My Sandbox (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.
Run Code Online (Sandbox Code Playgroud)

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

Joy*_*ang 11

我也可以在我这边重现您的问题,因为不同的Azure文件复制任务版本使用不同版本的AzCopyin Behind,然后它们使用不同的身份验证方式来调用API来执行操作。

有两种方法可以解决此问题。

  1. 如果您使用自动创建的服务连接,它应该Contributor在您的存储帐户中发挥作用,您可以使用 Azure 文件复制任务版本3.*而不是4.*,然后它就可以工作。

  2. 如果您想使用 Azure 文件复制任务版本4.*,请导航到您的存储帐户 -> Access Control (IAM)-> 将服务连接中使用的服务主体添加为角色,请参阅此处的Storage Blob Data Contributor详细步骤。它也会起作用。