Skip to content

Commit 3b955df

Browse files
committed
docs: add azure RBAC for access control
Signed-off-by: Yi Zha <[email protected]>
1 parent 93e3eac commit 3b955df

File tree

1 file changed

+61
-9
lines changed

1 file changed

+61
-9
lines changed

articles/container-registry/container-registry-tutorial-sign-build-push.md

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ In this tutorial:
6464
1. Configure AKV resource names.
6565
6666
```bash
67+
AKV_SUB_ID=myAkvSubscriptionId
68+
AKV_RG=myAkvResourceGroup
6769
# Name of the existing AKV used to store the signing keys
6870
AKV_NAME=myakv
6971
# Name of the certificate created in AKV
@@ -75,6 +77,8 @@ In this tutorial:
7577
2. Configure ACR and image resource names.
7678
7779
```bash
80+
ACR_SUB_ID=myAcrSubscriptionId
81+
ACR_RG=myAcrResourceGroup
7882
# Name of the existing registry example: myregistry.azurecr.io
7983
ACR_NAME=myregistry
8084
# Existing full domain of the ACR
@@ -95,23 +99,71 @@ az login
9599
96100
To learn more about Azure CLI and how to sign in with it, see [Sign in with Azure CLI](/cli/azure/authenticate-azure-cli).
97101
98-
## Assign access policy in AKV (Azure CLI)
102+
## Access control
99103
100-
A user principal with the correct access policy permissions is needed to create a self-signed certificate and sign artifacts. This principal can be a user principal, service principal, or managed identity. At a minimum, this principal needs the following permissions:
104+
When working with ACR and AKV, it’s essential to grant the appropriate permissions to ensure secure and controlled access. You can authorize access for different entities, such as user principals, service principals, or managed identities, depending on your specific scenarios. In this tutorial, the access are authorized to a signed-in Azure user.
101105
102-
- `Create` permissions for certificates
103-
- `Get` permissions for certificates
104-
- `Sign` permissions for keys
106+
### Authorize access to ACR
105107
106-
In this tutorial, the access policy is assigned to a signed-in Azure user. To learn more about assigning policy to a principal, see [Assign Access Policy](/azure/key-vault/general/assign-access-policy).
108+
The `AcrPull` and `AcrPush` roles are required for signing container images in ACR.
107109
108-
### Set the subscription that contains the AKV resource
110+
1. Set the subscription that contains the ACR resource
109111
110112
```bash
111-
az account set --subscription <your_subscription_id>
113+
az account set --subscription $ACR_SUB_ID
112114
```
113115
114-
### Set the access policy in AKV
116+
2. Assign the roles
117+
118+
```bash
119+
USER_ID=$(az ad signed-in-user show --query id -o tsv)
120+
az role assignment create --role "AcrPull" --role "AcrPush" --assignee $USER_ID --scope "/subscriptions/$ACR_SUB_ID/resourceGroups/$ACR_RG/providers/Microsoft.ContainerRegistry/registries/$ACR_NAME"
121+
```
122+
123+
### Authorize access to AKV
124+
125+
In this section, we’ll explore two options for authorizing access to AKV.
126+
127+
#### Use Azure RBAC (Recommended)
128+
129+
The following roles are required for signing using self-signed certificates:
130+
131+
- `Key Vault Certificates Officer` for creating and reading certificates
132+
- `Key Vault Certificates User`for reading existing certificates
133+
- `Key Vault Crypto User` for signing operations
134+
135+
To learn more about Key Vault access with Azure RBAC, see [Use an Azure RBAC for managing access](/azure/key-vault/general/rbac-guide).
136+
137+
1. Set the subscription that contains the AKV resource
138+
139+
```bash
140+
az account set --subscription $AKV_SUB_ID
141+
```
142+
143+
2. Assign the roles
144+
145+
```bash
146+
USER_ID=$(az ad signed-in-user show --query id -o tsv)
147+
az role assignment create --role "Key Vault Certificates Officer" --role "Key Vault Crypto User" --assignee $USER_ID --scope "/subscriptions/$AKV_SUB_ID/resourceGroups/$AKV_RG/providers/Microsoft.KeyVault/vaults/$AKV_NAME"
148+
```
149+
150+
#### Assign access policy in AKV (legacy)
151+
152+
The following permissions are required for an identity:
153+
154+
- `Create` permissions for creating a certificate
155+
- `Get` permissions for reading existing certificates
156+
- `Sign` permissions for signing operations
157+
158+
To learn more about assigning policy to a principal, see [Assign Access Policy](/azure/key-vault/general/assign-access-policy).
159+
160+
1. Set the subscription that contains the AKV resource:
161+
162+
```bash
163+
az account set --subscription $AKV_SUB_ID
164+
```
165+
166+
2. Set the access policy in AKV:
115167
116168
```bash
117169
USER_ID=$(az ad signed-in-user show --query id -o tsv)

0 commit comments

Comments
 (0)