【问题标题】:How to create a read only access key for Container Registry Azure如何为 Container Registry Azure 创建只读访问密钥
【发布时间】:2019-12-20 11:38:46
【问题描述】:

我在 Azure 上使用基本帐户类型。

我有:一个只有一个访问密钥(管理员)的私有注册表

我想要:能够创建更多具有只读(acrpull)访问权限的访问密钥。

问题:我从这里阅读是否正确:https://docs.microsoft.com/en-us/azure/container-registry/container-registry-skus#sku-feature-matrix 这是不允许的(仅在高级帐户中)?

有没有办法创建另一个仅在基本帐户上具有 acrpull 访问权限的令牌?

问候,

【问题讨论】:

  • 你有 azure 广告吗?
  • 不,我没有
  • az 广告用户列表 - 它正在显示一个用户,所以我想我确实拥有它 - 很可能是基本的用户列表

标签: azure acr


【解决方案1】:

当然可以。它使用服务主体进行身份验证。您需要为 ACR 创建一个分配有角色 acrpull 的服务主体。

这是一个使用 CLI 命令的示例脚本:

#!/bin/bash

# Modify for your environment.
# ACR_NAME: The name of your Azure Container Registry
# SERVICE_PRINCIPAL_NAME: Must be unique within your AD tenant
ACR_NAME=<container-registry-name>
SERVICE_PRINCIPAL_NAME=acr-service-principal

# Obtain the full registry ID for subsequent command args
ACR_REGISTRY_ID=$(az acr show --name $ACR_NAME --query id --output tsv)

# Create the service principal with rights scoped to the registry.
# Default permissions are for docker pull access. Modify the '--role'
# argument value as desired:
# acrpull:     pull only
# acrpush:     push and pull
# owner:       push, pull, and assign roles
SP_PASSWD=$(az ad sp create-for-rbac --name http://$SERVICE_PRINCIPAL_NAME --scopes $ACR_REGISTRY_ID --role acrpull --query password --output tsv)
SP_APP_ID=$(az ad sp show --id http://$SERVICE_PRINCIPAL_NAME --query appId --output tsv)

# Output the service principal's credentials; use these in your services and
# applications to authenticate to the container registry.
echo "Service principal ID: $SP_APP_ID"
echo "Service principal password: $SP_PASSWD"

您可以在Azure Container Registry authentication with service principals获取更多详细信息,也可以在查看Azure Container Registry roles and permissions时根据需要选择合适的角色。

【讨论】:

    猜你喜欢
    • 2022-01-27
    • 2018-04-04
    • 1970-01-01
    • 2019-09-25
    • 1970-01-01
    • 2021-07-26
    • 1970-01-01
    • 1970-01-01
    • 2021-12-21
    相关资源
    最近更新 更多