Skip to content

Commit 7fe5aaa

Browse files
authored
Merge pull request #229537 from tejaswikolli-web/cli
edits for azure cli- cache
2 parents 9638d48 + 5830482 commit 7fe5aaa

8 files changed

+274
-22
lines changed

articles/container-registry/TOC.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,14 @@
5454
items:
5555
- name: Caching for ACR - Overview
5656
href: tutorial-registry-cache.md
57-
- name: Enable Caching for ACR- Azure portal
57+
- name: Enable Caching for ACR - Azure portal
5858
href: tutorial-enable-registry-cache.md
59-
- name: Enable Caching for ACR with authentication- Azure portal
59+
- name: Enable Caching for ACR with authentication - Azure portal
6060
href: tutorial-enable-registry-cache-auth.md
61+
- name: Enable Caching for ACR - Azure CLI
62+
href: tutorial-enable-registry-cache-cli.md
63+
- name: Enable Caching for ACR with authentication - Azure CLI
64+
href: tutorial-enable-registry-cache-auth-cli.md
6165
- name: Troubleshoot
6266
href: tutorial-troubleshoot-registry-cache.md
6367
- name: Samples

articles/container-registry/container-registry-support-policies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.date: 10/11/2022
88
#Customer intent: As a developer, I want to understand what ACR components I need to manage, what components are managed by Microsoft.
99
---
1010

11-
# Support policies for Azure Container Registry(ACR)
11+
# Support policies for Azure Container Registry (ACR)
1212

1313
This article provides details about Azure Container Registry (ACR) support policies, supported features, and limitations.
1414

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
title: Enable Caching for ACR with authentication - Azure CLI
3+
description: Learn how to enable Caching for ACR with authentication using Azure CLI.
4+
ms.topic: tutorial
5+
ms.date: 04/19/2022
6+
ms.author: tejaswikolli
7+
---
8+
9+
# Enable Caching for ACR (Preview) with authentication - Azure CLI
10+
11+
This article is part five of a six-part tutorial series. [Part one](tutorial-registry-cache.md) provides an overview of Caching for ACR, its features, benefits, and preview limitations. In [part two](tutorial-enable-registry-cache.md), you learn how to enable Caching for ACR feature by using the Azure portal. In [part three](tutorial-enable-registry-cache-cli.md), you learn how to enable Caching for ACR feature by using the Azure CLI. In [part four](tutorial-enable-registry-cache-auth.md), you learn how to enable Caching for ACR feature with authentication by using Azure portal.
12+
13+
This article walks you through the steps of enabling Caching for ACR with authentication by using the Azure CLI. You have to use the Credential set to make an authenticated pull or to access a private repository.
14+
15+
## Prerequisites
16+
17+
* You can use the [Azure Cloud Shell][Azure Cloud Shell] or a local installation of the Azure CLI to run the command examples in this article. If you'd like to use it locally, version 2.0.74 or later is required. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][Install Azure CLI].
18+
* You have an existing Key Vault to store credentials. Learn more about [creating and storing credentials in a Key Vault.][create-and-store-keyvault-credentials]
19+
* You can set and retrieve secrets from your Key Vault. Learn more about [set and retrieve a secret from Key Vault.][set-and-retrieve-a-secret]
20+
21+
## Configure Caching for ACR (preview) with authentication - Azure CLI
22+
23+
### Create a Credential Set - Azure CLI
24+
25+
Before configuring a Credential Set, you have to create and store secrets in the Azure KeyVault and retrieve the secrets from the Key Vault. Learn more about [creating and storing credentials in a Key Vault.][create-and-store-keyvault-credentials] and to [set and retrieve a secret from Key Vault.][set-and-retrieve-a-secret].
26+
27+
1. Run [az acr credential set create][az-acr-credential-set-create] command to create a credential set.
28+
29+
- For example, To create a credential set for a given `MyRegistry` Azure Container Registry.
30+
31+
```azurecli-interactive
32+
az acr credential-set create
33+
-r MyRegistry \
34+
-n MyRule \
35+
-l docker.io \
36+
-u https://MyKeyvault.vault.azure.net/secrets/usernamesecret \
37+
-p https://MyKeyvault.vault.azure.net/secrets/passwordsecret
38+
```
39+
40+
2. Run [az acr credential set update][az-acr-credential-set-update] to update the username or password KV secret ID on a credential set.
41+
42+
- For example, to update the username or password KV secret ID on a credential set a given `MyRegistry` Azure Container Registry.
43+
44+
```azurecli-interactive
45+
az acr credential-set update -r MyRegistry -n MyRule -p https://MyKeyvault.vault.azure.net/secrets/newsecretname
46+
```
47+
48+
3. Run [az-acr-credential-set-show][az-acr-credential-set-show] to show a credential set.
49+
50+
- For example, to show a credential set for a given `MyRegistry` Azure Container Registry.
51+
52+
```azurecli-interactive
53+
az acr credential-set show -r MyRegistry -n MyCredSet
54+
```
55+
56+
### Create a cache rule with a Credential Set - Azure CLI
57+
58+
1. Run [az acr cache create][az-acr-cache-create] command to create a cache rule.
59+
60+
- For example, to create a cache rule with a credential set for a given `MyRegistry` Azure Container Registry.
61+
62+
```azurecli-interactive
63+
az acr cache create -r MyRegistry -n MyRule -s docker.io/library/ubuntu -t ubuntu -c MyCredSet
64+
```
65+
66+
2. Run [az acr cache update][az-acr-cache-update] command to update the credential set on a cache rule.
67+
68+
- For example, to update the credential set on a cache rule for a given `MyRegistry` Azure Container Registry.
69+
70+
```azurecli-interactive
71+
az acr cache update -r MyRegistry -n MyRule -c NewCredSet
72+
```
73+
74+
- For example, to remove a credential set from an existing cache rule for a given `MyRegistry` Azure Container Registry.
75+
76+
```azurecli-interactive
77+
az acr cache update -r MyRegistry -n MyRule --remove-cred-set
78+
```
79+
80+
3. Run [az acr cache show][az-acr-cache-show] command to show a cache rule.
81+
82+
- For example, to show a cache rule for a given `MyRegistry` Azure Container Registry.
83+
84+
```azurecli-interactive
85+
az acr cache show -r MyRegistry -n MyRule
86+
```
87+
88+
### Assign permissions to Key Vault
89+
90+
1. Get the principal ID of system identity in use to access Key Vault.
91+
92+
```azurecli-interactive
93+
PRINCIPAL_ID=$(az acr credential-set show
94+
-n MyCredSet \
95+
-r MyRegistry \
96+
--query 'identity.principalId' \
97+
-o tsv)
98+
```
99+
100+
2. Run the [az keyvault set-policy][az-keyvault-set-policy] command to assign access to the Key Vault, before pulling the image.
101+
102+
- For example, to assign permissions for the credential set access the KeyVault secret
103+
104+
```azurecli-interactive
105+
az keyvault set-policy --name MyKeyVault \
106+
--object-id $PRINCIPAL_ID \
107+
--secret-permissions get
108+
```
109+
110+
### Pull your Image
111+
112+
1. Pull the image from your cache using the Docker command `docker pull myregistry.azurecr.io/hello-world`
113+
114+
## Clean up the resources
115+
116+
1. Run [az acr cache list][az-acr-cache-list] command to list the cache rules in the Azure Container Registry.
117+
118+
- For example, to list the cache rules for a given `MyRegistry` Azure Container Registry.
119+
120+
```azurecli-interactive
121+
az acr cache list -r MyRegistry
122+
```
123+
124+
2. Run [az acr cache delete][az-acr-cache-delete] command to delete a cache rule.
125+
126+
- For example, to delete a cache rule for a given `MyRegistry` Azure Container Registry.
127+
128+
```azurecli-interactive
129+
az acr cache delete -r MyRegistry -n MyRule
130+
```
131+
132+
3. Run[az acr credential set list][az-acr-credential-set-list] to list the credential sets in an Azure Container Registry.
133+
134+
- For example, to list the credential sets for a given `MyRegistry` Azure Container Registry.
135+
136+
```azurecli-interactive
137+
az acr credential-set list -r MyRegistry
138+
```
139+
140+
4. Run [az-acr-credential-set-delete][az-acr-credential-set-delete] to delete a credential set.
141+
142+
- For example, to delete a credential set for a given `MyRegistry` Azure Container Registry.
143+
144+
```azurecli-interactive
145+
az acr credential-set delete -r MyRegistry -n MyCredSet
146+
```
147+
148+
## Next steps
149+
150+
* Advance to the [next article](tutorial-troubleshoot-registry-cache.md) to walk through the troubleshoot guide for Registry Cache.
151+
152+
<!-- LINKS - External -->
153+
[create-and-store-keyvault-credentials]: ../key-vault/secrets/quick-create-cli.md#add-a-secret-to-key-vault
154+
[set-and-retrieve-a-secret]: ../key-vault/secrets/quick-create-cli.md#retrieve-a-secret-from-key-vault
155+
[az-keyvault-set-policy]: ../key-vault/general/assign-access-policy.md#assign-an-access-policy
156+
[Install Azure CLI]: /cli/azure/install-azure-cli
157+
[Azure Cloud Shell]: /azure/cloud-shell/quickstart
158+
[az-acr-cache-create]:/cli/azure/acr/cache#az-acr-cache-create
159+
[az-acr-cache-show]:/cli/azure/acr/cache#az-acr-cache-show
160+
[az-acr-cache-list]:/cli/azure/acr/cache#az-acr-cache-list
161+
[az-acr-cache-delete]:/cli/azure/acr/cache#az-acr-cache-delete
162+
[az-acr-cache-update]:/cli/azure/acr/cache#az-acr-cache-update
163+
[az-acr-credential-set-create]:/cli/azure/acr/credential-set#az-acr-credential-set-create
164+
[az-acr-credential-set-update]:/cli/azure/acr/credential-set#az-acr-credential-set-update
165+
[az-acr-credential-set-show]: /cli/azure/acr/credential-set#az-acr-credential-set-show
166+
[az-acr-credential-set-list]: /cli/azure/acr/credential-set#az-acr-credential-set-list
167+
[az-acr-credential-set-delete]: /cli/azure/acr/credential-set#az-acr-credential-set-delete

articles/container-registry/tutorial-enable-registry-cache-auth.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Enable Caching for ACR with authentication- Azure portal
2+
title: Enable Caching for ACR with authentication - Azure portal
33
description: Learn how to enable Caching for ACR with authentication using Azure portal.
44
ms.topic: tutorial
55
ms.date: 04/19/2022
@@ -8,16 +8,16 @@ ms.author: tejaswikolli
88

99
# Enable Caching for ACR (Preview) with authentication - Azure portal
1010

11-
This article is part three of a four-part tutorial series. [Part one](tutorial-registry-cache.md) provides an overview of Caching for ACR, its features, benefits, and preview limitations. In [part two](tutorial-enable-registry-cache.md), you learn how to enable Caching for ACR feature by using the Azure portal.
11+
This article is part four of a six-part tutorial series. [Part one](tutorial-registry-cache.md) provides an overview of Caching for ACR, its features, benefits, and preview limitations. In [part two](tutorial-enable-registry-cache.md), you learn how to enable Caching for ACR feature by using the Azure portal. In [part three](tutorial-enable-registry-cache-cli.md) , you learn how to enable Caching for ACR feature by using the Azure CLI.
1212

1313
This article walks you through the steps of enabling Caching for ACR with authentication by using the Azure portal. You have to use the Credential set to make an authenticated pull or to access a private repository.
1414

1515
## Prerequisites
1616

1717
* Sign in to the [Azure portal](https://ms.portal.azure.com/).
18+
* You have an existing Key Vault to store credentials. Learn more about [creating and storing credentials in a Key Vault.][create-and-store-keyvault-credentials]
1819

19-
20-
## Configure Caching for ACR with authentication - Azure portal
20+
## Configure Caching for ACR (preview) with authentication - Azure portal
2121

2222
Follow the steps to create cache rule in the [Azure portal](https://portal.azure.com).
2323

@@ -61,16 +61,22 @@ Follow the steps to create cache rule in the [Azure portal](https://portal.azure
6161

6262
12. Select on **Save**
6363

64-
13. Run the [az keyvault set-policy][az-keyvault-set-policy] command to assign access to the Key Vault, before pulling the image.
64+
13. Learn about [az keyvault set-policy][az-keyvault-set-policy] to assign access to the Key Vault, before pulling the image.
65+
66+
- For example, to assign permissions for the credential set access the KeyVault secret
6567

66-
```azurecli-interactive
67-
az keyvault set-policy --name myKeyVaultName --object-id myObjID --secret-permissions get
68-
```
68+
```azurecli-interactive
69+
az keyvault set-policy --name MyKeyVault \
70+
--object-id $PRINCIPAL_ID \
71+
--secret-permissions get
72+
```
6973
7074
14. Pull the image from your cache using the Docker command `docker pull myregistry.azurecr.io/hello-world`
7175
7276
### Create new credentials
7377
78+
Before configuring a Credential Set, you require to create and store secrets in the Azure KeyVault and retrieve the secrets from the Key Vault. Learn more about [creating and storing credentials in a Key Vault.][create-and-store-keyvault-credentials] and to [set and retrieve a secret from Key Vault.][set-and-retrieve-a-secret].
79+
7480
1. Navigate to **Credentials** > **Add credential set** > **Create new credentials**.
7581
7682
@@ -90,8 +96,9 @@ az keyvault set-policy --name myKeyVaultName --object-id myObjID --secret-permis
9096
9197
## Next steps
9298
93-
* Advance to the [next article](tutorial-troubleshoot-registry-cache.md) to walk through the troubleshoot guide for Registry Cache.
99+
* Advance to the [next article](tutorial-enable-registry-cache-cli.md) to enable the Caching for ACR (preview) using Azure CLI.
94100
95101
<!-- LINKS - External -->
96-
[create-and-store-keyvault-credentials]: ../key-vault/secrets/quick-create-portal.md
97-
[az-keyvault-set-policy]: /azure/key-vault/general/assign-access-policy.md#assign-an-access-policy
102+
[create-and-store-keyvault-credentials]: ../key-vault/secrets/quick-create-portal.md#add-a-secret-to-key-vault
103+
[set-and-retrieve-a-secret]: ../key-vault/secrets/quick-create-portal.md#retrieve-a-secret-from-key-vault
104+
[az-keyvault-set-policy]: ../key-vault/general/assign-access-policy.md#assign-an-access-policy
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: Enable Caching for ACR (preview) - Azure CLI
3+
description: Learn how to enable Registry Cache in your Azure Container Registry using Azure CLI.
4+
ms.topic: tutorial
5+
ms.date: 04/19/2022
6+
ms.author: tejaswikolli
7+
---
8+
9+
# Enable Caching for ACR (Preview) - Azure CLI
10+
11+
This article is part three of a six-part tutorial series. [Part one](tutorial-registry-cache.md) provides an overview of Caching for ACR, its features, benefits, and preview limitations. [Part two](tutorial-enable-registry-cache.md), you learn how to enable Caching for ACR feature by using the Azure portal. This article walks you through the steps of enabling Caching for ACR by using the Azure CLI without authentication.
12+
13+
## Prerequisites
14+
15+
* You can use the [Azure Cloud Shell][Azure Cloud Shell] or a local installation of the Azure CLI to run the command examples in this article. If you'd like to use it locally, version 2.0.74 or later is required. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][Install Azure CLI].
16+
17+
## Configure Caching for ACR (preview) - Azure CLI
18+
19+
Follow the steps to create a cache rule without using a Credential set.
20+
21+
### Create a Cache rule
22+
23+
1. Run [az acr cache create][az-acr-cache-create] command to create a cache rule.
24+
25+
- For example, to create a cache rule without a credential set for a given `MyRegistry` Azure Container Registry.
26+
27+
```azurecli-interactive
28+
az acr cache create -r MyRegistry -n MyRule -s docker.io/library/ubuntu -t ubuntu-
29+
```
30+
31+
2. Run [az acr cache show][az-acr-cache-show] command to show a cache rule.
32+
33+
- For example, to show a cache rule for a given `MyRegistry` Azure Container Registry.
34+
35+
```azurecli-interactive
36+
az acr cache show -r MyRegistry -n MyRule
37+
```
38+
39+
### Pull your image
40+
41+
1. Pull the image from your cache using the Docker command `docker pull myregistry.azurecr.io/hello-world`.
42+
43+
44+
## Clean up the resources
45+
46+
1. Run [az acr cache list][az-acr-cache-list] command to list the cache rules in the Azure Container Registry.
47+
48+
- For example, to list the cache rules for a given `MyRegistry` Azure Container Registry.
49+
50+
```azurecli-interactive
51+
az acr cache list -r MyRegistry
52+
```
53+
54+
2. Run [az acr cache delete][az-acr-cache-delete] command to delete a cache rule.
55+
56+
- For example, to delete a cache rule for a given `MyRegistry` Azure Container Registry.
57+
58+
```azurecli-interactive
59+
az acr cache delete -r MyRegistry -n MyRule
60+
```
61+
62+
## Next steps
63+
64+
* To enable Caching for ACR (preview) with authentication using the Azure CLI advance to the next article [Enable Caching for ACR - Azure CLI](tutorial-enable-registry-cache-auth-cli.md).
65+
66+
<!-- LINKS - External -->
67+
[Install Azure CLI]: /cli/azure/install-azure-cli
68+
[Azure Cloud Shell]: /azure/cloud-shell/quickstart
69+
[az-acr-cache-create]:/cli/azure/acr/cache#az-acr-cache-create
70+
[az-acr-cache-show]:/cli/azure/acr/cache#az-acr-cache-show
71+
[az-acr-cache-list]:/cli/azure/acr/cache#az-acr-cache-list
72+
[az-acr-cache-delete]:/cli/azure/acr/cache#az-acr-cache-delete

articles/container-registry/tutorial-enable-registry-cache.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Enable Caching for ACR (preview)- Azure portal
2+
title: Enable Caching for ACR (preview) - Azure portal
33
description: Learn how to enable Registry Cache in your Azure Container Registry using Azure portal.
44
ms.topic: tutorial
55
ms.date: 04/19/2022
@@ -8,11 +8,11 @@ ms.author: tejaswikolli
88

99
# Enable Caching for ACR (Preview) - Azure portal
1010

11-
This article is part two of a four-part tutorial series. [Part one](tutorial-registry-cache.md) provides an overview of Caching for ACR, its features, benefits, and preview limitations. This article walks you through the steps of enabling Caching for ACR by using the Azure portal.
11+
This article is part two of a six-part tutorial series. [Part one](tutorial-registry-cache.md) provides an overview of Caching for ACR, its features, benefits, and preview limitations. This article walks you through the steps of enabling Caching for ACR by using the Azure portal without authentication.
1212

1313
## Prerequisites
1414

15-
* Sign in to the [Azure portal](https://ms.portal.azure.com/).
15+
* Sign in to the [Azure portal](https://ms.portal.azure.com/)
1616

1717
## Configure Caching for ACR (preview) - Azure portal
1818

@@ -58,7 +58,7 @@ Follow the steps to create cache rule in the [Azure portal](https://portal.azure
5858

5959
## Next steps
6060

61-
* Advance to the [next article](tutorial-enable-registry-cache-auth.md) to enable the Caching for ACR (preview) with authentication using Azure portal.
61+
* Advance to the [next article](tutorial-enable-registry-cache-cli.md) to enable the Caching for ACR (preview) using Azure CLI.
6262

6363
<!-- LINKS - External -->
6464
[create-and-store-keyvault-credentials]:../key-vault/secrets/quick-create-portal.md

articles/container-registry/tutorial-registry-cache.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ ms.author: tejaswikolli
99

1010
Caching for Azure Container Registry (Preview) feature allows users to cache container images in a private container registry. Caching for ACR, is a preview feature available in *Basic*, *Standard*, and *Premium* [service tiers](container-registry-skus.md).
1111

12-
This article is part one in a four-part tutorial series. The tutorial covers:
12+
This article is part one in a six-part tutorial series. The tutorial covers:
1313

1414
> [!div class="checklist"]
1515
> * Caching for ACR (preview)
1616
> * Enable Caching for ACR - Azure portal
1717
> * Enable Caching for ACR with authentication - Azure portal
18+
> * Enable Caching for ACR - Azure CLI
19+
> * Enable Caching for ACR with authentication - Azure CLI
1820
> * Troubleshooting guide for Caching for ACR
1921
2022
## Caching for ACR (Preview)
@@ -63,7 +65,7 @@ Implementing Caching for ACR provides the following benefits:
6365

6466
- Caching for ACR only supports 50 cache rules.
6567

66-
- Caching for ACR is only available by using the Azure portal. The Azure CLI is in target for the coming weeks.
68+
- Caching for ACR is only available by using the Azure portal and Azure CLI.
6769

6870
## Next steps
6971

0 commit comments

Comments
 (0)