Azure 存储容器角色

问题描述 投票:0回答:1

使用服务主体,我尝试在 Azure 资源组中定义两个角色,其中一个角色用于主持人:

az role assignment create --assignee <moderator app id> --role "Storage Blob Data Owner" --scope /subscriptions/<mysub>/resourceGroups/<myresourcegroup>

还有一个给读者的:

az role assignment create --assignee <readerapp id> --role "Storage Blob Data Reader" --scope /subscriptions/<mysub>/resourceGroups/<myresourcegroup>

主持人可以使用以下方式将文件上传到容器: azcopy 复制“https://.blob.core.windows.net/”--recursive=true

但是当读者尝试从容器中获取内容时: azcopy 复制 "https://.blob.core.windows.net/" "" --recursive=true --overwrite ifSourceNewer ...命令失败并显示

failed to perform copy command due to error: cannot start job due to error: cannot list files due to reason -> github.com/Azure/azure-storage-blob-go/azblob.newStorageError, C:/Users/VssAdministrator/go/pkg/mod/github.com/!azure/[email protected]/azblob/zc_storage_error.go:42

当我进入门户并将“存储 Blob 读取器”角色添加到容器(而不是资源组)时,读取器角色能够

azcopy
容器的内容。

如何从 azure-cli 在容器级别添加角色,为什么有必要?

azure azure-cli
1个回答
0
投票

如何从 azure-cli 在容器级别添加角色,为什么有必要?

要将

storage blob data reader role
分配给容器级别,您可以使用以下命令:

命令:

az role assignment create --assignee <readerapp id> --role "Storage Blob Data Reader" --scope /subscriptions/<mysub>/resourceGroups/<myresourcegroup>/providers/Microsoft.Storage/storageAccounts/<storage-account>/blobServices/default/containers/<container-name

输出:

enter image description here

现在我可以使用 Azcopy 命令获取内容。

传送门:

在我的容器中,我有一些文件。

enter image description here

首先,我使用应用程序凭据登录,并使用以下命令:

azcopy copy "https://youraccountname.blob.core.windows.net/test/*" "C:\Users\xx\xxx\input" --recursive=true 

输出: enter image description here

文件: enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.