簡體   English   中英

如何為容器注冊表 Azure 創建只讀訪問密鑰

[英]How to create a read only access key for Container Registry Azure

我在 Azure 上使用基本帳戶類型。

我有:一個只有一個訪問密鑰的私有注冊表(管理員)

我想要:能夠創建更多具有只讀(acrpull)訪問權限的訪問密鑰。

問題:我從這里閱讀是否正確: https : //docs.microsoft.com/en-us/azure/container-registry/container-registry-skus#sku-feature-matrix這是不允許的(僅在高級版中)帳戶)?

有沒有辦法僅在基本帳戶上創建另一個具有 acrpull 訪問權限的令牌?

問候,

當然可以。 它使用服務主體進行身份驗證。 您需要為 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 身份驗證中獲取更多詳細信息, 使用服務主體,也可以在查看Azure Container Registry 角色和權限時根據需要選擇合適的角色。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM