Skip to content

Commit 20f470e

Browse files
authored
Merge pull request #109928 from dlepow/acrfix
[ACR] Token updates
2 parents 3023cc8 + 1ff2ee3 commit 20f470e

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-28
lines changed

articles/container-registry/container-registry-repository-scoped-permissions.md

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Permissions to repositories in Azure Container Registry
33
description: Create a token with permissions scoped to specific repositories in a registry to pull or push images, or perform other actions
44
ms.topic: article
5-
ms.date: 02/13/2020
5+
ms.date: 05/27/2020
66
---
77

88
# Create a token with repository-scoped permissions
@@ -15,12 +15,13 @@ Scenarios for creating a token include:
1515
* Provide an external organization with permissions to a specific repository
1616
* Limit repository access to different user groups in your organization. For example, provide write and read access to developers who build images that target specific repositories, and read access to teams that deploy from those repositories.
1717

18+
This feature is available in **Premium** container registries. For information about registry service tiers and limits, see [Azure Container Registry service tiers](container-registry-skus.md).
19+
1820
> [!IMPORTANT]
1921
> This feature is currently in preview, and some [limitations apply](#preview-limitations). Previews are made available to you on the condition that you agree to the [supplemental terms of use][terms-of-use]. Some aspects of this feature may change prior to general availability (GA).
2022
2123
## Preview limitations
2224

23-
* This feature is available in **Premium** container registries. For information about registry service tiers and limits, see [Azure Container Registry service tiers](container-registry-skus.md).
2425
* You can't currently assign repository-scoped permissions to an Azure Active Directory identity, such as a service principal or managed identity.
2526
* You can't create a scope map in a registry enabled for [anonymous pull access](container-registry-faq.md#how-do-i-enable-anonymous-pull-access).
2627

@@ -47,7 +48,7 @@ To configure repository-scoped permissions, you create a *token* with an associa
4748
* Configure multiple tokens with identical permissions to a set of repositories
4849
* Update token permissions when you add or remove repository actions in the scope map, or apply a different scope map
4950

50-
Azure Container Registry also provides several system-defined scope maps you can apply, with fixed permissions across all repositories.
51+
Azure Container Registry also provides several system-defined scope maps you can apply when creating tokens. The permissions of system-defined scope maps apply to all repositories in your registry.
5152

5253
The following image shows the relationship between tokens and scope maps.
5354

@@ -63,7 +64,7 @@ The following image shows the relationship between tokens and scope maps.
6364

6465
### Create token and specify repositories
6566

66-
Create a token using the [az acr token create][az-acr-token-create] command. When creating a token, you can specify one or more repositories and associated actions on each repository. The repositories don't need to be in the registry yet. To create a token by specifying an existing scope map, see the next section.
67+
Create a token using the [az acr token create][az-acr-token-create] command. When creating a token, you can specify one or more repositories and associated actions on each repository. The repositories don't need to be in the registry yet. To create a token by specifying an existing scope map, see the [next section](#create-token-and-specify-scope-map).
6768

6869
The following example creates a token in the registry *myregistry* with the following permissions on the `samples/hello-world` repo: `content/write` and `content/read`. By default, the command sets the default token status to `enabled`, but you can update the status to `disabled` at any time.
6970

@@ -73,7 +74,7 @@ az acr token create --name MyToken --registry myregistry \
7374
content/write content/read
7475
```
7576

76-
The output shows details about the token, including two generated passwords. It's recommended to save the passwords in a safe place to use later for authentication. The passwords can't be retrieved again, but new ones can be generated.
77+
The output shows details about the token. By default, two passwords are generated. It's recommended to save the passwords in a safe place to use later for authentication. The passwords can't be retrieved again, but new ones can be generated.
7778

7879
```console
7980
{
@@ -106,6 +107,9 @@ The output shows details about the token, including two generated passwords. It'
106107
"type": "Microsoft.ContainerRegistry/registries/tokens"
107108
```
108109

110+
> [!NOTE]
111+
> If you want to regenerate token passwords and set password expiration periods, see [Regenerate token passwords](#regenerate-token-passwords) later in this article.
112+
109113
The output includes details about the scope map the command created. You can use the scope map, here named `MyToken-scope-map`, to apply the same repository actions to other tokens. Or, update the scope map later to change the permissions of the associated tokens.
110114

111115
### Create token and specify scope map
@@ -129,7 +133,10 @@ az acr token create --name MyToken \
129133
--scope-map MyScopeMap
130134
```
131135

132-
The output shows details about the token, including two generated passwords. It's recommended to save the passwords in a safe place to use later for authentication. The passwords can't be retrieved again, but new ones can be generated.
136+
The output shows details about the token. By default, two passwords are generated. It's recommended to save the passwords in a safe place to use later for authentication. The passwords can't be retrieved again, but new ones can be generated.
137+
138+
> [!NOTE]
139+
> If you want to regenerate token passwords and set password expiration periods, see [Regenerate token passwords](#regenerate-token-passwords) later in this article.
133140
134141
## Create token - portal
135142

@@ -138,14 +145,16 @@ You can use the Azure portal to create tokens and scope maps. As with the `az ac
138145
The following example creates a token, and creates a scope map with the following permissions on the `samples/hello-world` repository: `content/write` and `content/read`.
139146

140147
1. In the portal, navigate to your container registry.
141-
1. Under **Services**, select **Tokens (Preview) > +Add**.
142-
![Create token in portal](media/container-registry-repository-scoped-permissions/portal-token-add.png)
148+
1. Under **Repository permissions**, select **Tokens (Preview) > +Add**.
149+
150+
:::image type="content" source="media/container-registry-repository-scoped-permissions/portal-token-add.png" alt-text="Create token in portal":::
143151
1. Enter a token name.
144152
1. Under **Scope map**, select **Create new**.
145153
1. Configure the scope map:
146154
1. Enter a name and description for the scope map.
147155
1. Under **Repositories**, enter `samples/hello-world`, and under **Permissions**, select `content/read` and `content/write`. Then select **+Add**.
148-
![Create scope map in portal](media/container-registry-repository-scoped-permissions/portal-scope-map-add.png)
156+
157+
:::image type="content" source="media/container-registry-repository-scoped-permissions/portal-scope-map-add.png" alt-text="Create scope map in portal":::
149158

150159
1. After adding repositories and permissions, select **Add** to add the scope map.
151160
1. Accept the default token **Status** of **Enabled** and then select **Create**.
@@ -154,26 +163,26 @@ After the token is validated and created, token details appear in the **Tokens**
154163

155164
### Add token password
156165

157-
Generate a password after you create a token. To authenticate with the registry, the token must be enabled and have a valid password.
158-
159-
You can generate one or two passwords, and set an expiration date for each one.
166+
To use a token created in the portal, you must generate a password. You can generate one or two passwords, and set an expiration date for each one.
160167

161168
1. In the portal, navigate to your container registry.
162-
1. Under **Services**, select **Tokens (Preview)**, and select a token.
169+
1. Under **Repository permissions**, select **Tokens (Preview)**, and select a token.
163170
1. In the token details, select **password1** or **password2**, and select the Generate icon.
164-
1. In the password screen, optionally set an expiration date for the password, and select **Generate**.
171+
1. In the password screen, optionally set an expiration date for the password, and select **Generate**. It's recommended to set an expiration date.
165172
1. After generating a password, copy and save it to a safe location. You can't retrieve a generated password after closing the screen, but you can generate a new one.
166173

167-
![Create token password in portal](media/container-registry-repository-scoped-permissions/portal-token-password.png)
174+
:::image type="content" source="media/container-registry-repository-scoped-permissions/portal-token-password.png" alt-text="Create token password in portal":::
168175

169176
## Authenticate with token
170177

171-
When a user or service uses a token to authenticate with the target registry, it provides the token name as a user name and one of its generated passwords. The authentication method depends on the configured action or actions associated with the token.
178+
When a user or service uses a token to authenticate with the target registry, it provides the token name as a user name and one of its generated passwords.
179+
180+
The authentication method depends on the configured action or actions associated with the token.
172181

173182
|Action |How to authenticate |
174183
|---------|---------|
175-
|`content/delete` | `az acr repository delete` in Azure CLI |
176-
|`content/read` | `docker login`<br/><br/>`az acr login` in Azure CLI |
184+
|`content/delete` | `az acr repository delete` in Azure CLI<br/><br/>Example: `az acr repository delete --name myregistry --repository myrepo --username MyToken --password xxxxxxxxxx`|
185+
|`content/read` | `docker login`<br/><br/>`az acr login` in Azure CLI<br/><br/>Example: `az acr login --name myregistry --username MyToken --password xxxxxxxxxx` |
177186
|`content/write` | `docker login`<br/><br/>`az acr login` in Azure CLI |
178187
|`metadata/read` | `az acr repository show`<br/><br/>`az acr repository show-tags`<br/><br/>`az acr repository show-manifests` in Azure CLI |
179188
|`metadata/write` | `az acr repository untag`<br/><br/>`az acr repository update` in Azure CLI |
@@ -195,7 +204,7 @@ docker tag hello-world myregistry.azurecr.io/samples/alpine:v1
195204

196205
### Authenticate using token
197206

198-
Run `docker login` to authenticate with the registry, Provide the token name as the user name, and provide one of its passwords. The token must have the `Enabled` status.
207+
Run `docker login` or `az acr login` to authenticate with the registry to push or pull images. Provide the token name as the user name, and provide one of its passwords. The token must have the `Enabled` status.
199208

200209
The following example is formatted for the bash shell, and provides the values using environment variables.
201210

@@ -226,7 +235,7 @@ The token doesn't have permissions to the `samples/alpine` repo, so the followin
226235
docker push myregistry.azurecr.io/samples/alpine:v1
227236
```
228237

229-
### Change push/pull permissions
238+
### Update token permissions
230239

231240
To update the permissions of a token, update the permissions in the associated scope map. The updated scope map is applied immediately to all associated tokens.
232241

@@ -245,7 +254,7 @@ az acr scope-map update \
245254
In the Azure portal:
246255

247256
1. Navigate to your container registry.
248-
1. Under **Services**, select **Scope maps (Preview)**, and select the scope map to update.
257+
1. Under **Repository permissions**, select **Scope maps (Preview)**, and select the scope map to update.
249258
1. Under **Repositories**, enter `samples/alpine`, and under **Permissions**, select `content/read` and `content/write`. Then select **+Add**.
250259
1. Under **Repositories**, select `samples/hello-world` and under **Permissions**, deselect `content/write`. Then select **Save**.
251260

@@ -280,9 +289,9 @@ az acr scope-map update \
280289
--add samples/alpine content/delete
281290
```
282291

283-
To update the scope map using the portal, see the preceding section.
292+
To update the scope map using the portal, see the [previous section](#update-token-permissions).
284293

285-
Use the following [az acr repository delete][az-acr-repository-delete] command to delete the `samples/alpine` repository. To delete images or repositories, the token doesn't authenticate through `docker login`. Instead, pass the token's name and password to the command. The following example uses the environment variables created earlier in the article:
294+
Use the following [az acr repository delete][az-acr-repository-delete] command to delete the `samples/alpine` repository. To delete images or repositories, pass the token's name and password to the command. The following example uses the environment variables created earlier in the article:
286295

287296
```azurecli
288297
az acr repository delete \
@@ -303,11 +312,11 @@ az acr scope-map update \
303312
--add samples/hello-world metadata/read
304313
```
305314

306-
To update the scope map using the portal, see the preceding section.
315+
To update the scope map using the portal, see the [previous section](#update-token-permissions).
307316

308317
To read metadata in the `samples/hello-world` repository, run the [az acr repository show-manifests][az-acr-repository-show-manifests] or [az acr repository show-tags][az-acr-repository-show-tags] command.
309318

310-
To read metadata, the token doesn't authenticate through `docker login`. Instead, pass the token's name and password to either command. The following example uses the environment variables created earlier in the article:
319+
To read metadata, pass the token's name and password to either command. The following example uses the environment variables created earlier in the article:
311320

312321
```azurecli
313322
az acr repository show-tags \
@@ -322,6 +331,7 @@ Sample output:
322331
"v1"
323332
]
324333
```
334+
325335
## Manage tokens and scope maps
326336

327337
### List scope maps
@@ -333,7 +343,7 @@ az acr scope-map list \
333343
--registry myregistry --output table
334344
```
335345

336-
The output shows the scope maps you defined and several system-defined scope maps you can use to configure tokens:
346+
The output consists of the three system-defined scope maps and other scope maps generated by you. Tokens can be configured with any of these scope maps.
337347

338348
```
339349
NAME TYPE CREATION DATE DESCRIPTION
@@ -359,9 +369,9 @@ Use the [az acr token list][az-acr-token-list] command, or the **Tokens (Preview
359369
az acr token list --registry myregistry --output table
360370
```
361371

362-
### Generate passwords for token
372+
### Regenerate token passwords
363373

364-
If you don't have a token password, or you want to generate new passwords, run the [az acr token credential generate][az-acr-token-credential-generate] command.
374+
If you didn't generate a token password, or you want to generate new passwords, run the [az acr token credential generate][az-acr-token-credential-generate] command.
365375

366376
The following example generates a new value for password1 for the *MyToken* token, with an expiration period of 30 days. It stores the password in the environment variable `TOKEN_PWD`. This example is formatted for the bash shell.
367377

-79.5 KB
Loading
-113 KB
Loading
-86.1 KB
Loading

0 commit comments

Comments
 (0)