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

How to grant access to Azure File Copy of Azure Pipeline to Azure Storage?

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

我正在按照 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.

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

我也可以在我这边重现你的问题,因为不同的 Azure 文件复制任务版本在后面使用不同版本的 AzCopy,然后他们使用不同的身份验证方式调用 API 来做操作。

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

  1. 如果您使用自动创建的服务连接,它应该在您的存储帐户中具有 Contributor 角色,您可以使用 Azure 文件复制任务版本 3.* 而不是 4.*,那么就可以了。

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