我正在尝试使用 Azure AD 设置对 Azure 容器注册表的简单只读访问。
我已成功设置具有只读访问权限的服务主体,没有问题,但是在创建 AD 帐户并在注册表上使用 IAM 时,我无法使用 az acr 登录。
我已在 Azure AD 中创建了一个帐户,将其添加到注册表 IAM,为其分配了读者角色(这与为服务主体指定的角色匹配),但使用 az acr 登录时收到以下错误
The client '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="473f3f3f3f073f3f3f3f3f3f69242869322c" rel="noreferrer noopener nofollow">[email protected]</a>' with object id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' does not have authorization to perform action 'Microsoft.ContainerRegistry/registries/listCredentials/action' over scope '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx/resourceGroups/xxxxxxxxxxxxx/providers/Microsoft.ContainerRegistry/registries/xxxxxxxxxxxx'.
使用 az acr 登录的唯一方法是分配对资源组的 IAM 贡献者权限。
我有什么遗漏吗?
蒂亚
最佳答案
这是一个 RBAC 问题。
您可以尝试使用此docker登录
来登录ACR吗?
您还可以使用服务主体
直接登录。向 docker 登录命令提供服务主体的应用 ID 和密码:
docker login myregistry.azurecr.io -u xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -p myPassword
当您使用 az acr login
登录时,CLI 使用您执行 az login
时创建的 token 来无缝验证您的 session 您的注册表。
请检查您的服务主体权限,您也可以创建新的服务主体并分配给此组。
az ad sp create-for-rbac -n "http://my-app" --role reader --scopes /subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/mygroup
可用的角色有:
读者:拉
贡献者:拉和推
所有者:拉取、推送以及将角色分配给其他用户
注意:
当您使用az acr login
登录acr时,此命令将使用您执行az acr login
时创建的 token 来登录它。此 token 不等于您的服务主体(读取器)。
关于Azure 容器注册表权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48754308/