|
| 1 | +--- |
| 2 | +title: Enable Caching for ACR with authentication- Azure portal |
| 3 | +description: Learn how to enable Caching for ACR with authentication using Azure portal. |
| 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 portal |
| 10 | + |
| 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. |
| 12 | + |
| 13 | +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. |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +* Sign in to the [Azure portal](https://ms.portal.azure.com/). |
| 18 | + |
| 19 | + |
| 20 | +## Configure Caching for ACR with authentication - Azure portal |
| 21 | + |
| 22 | +Follow the steps to create cache rule in the [Azure portal](https://portal.azure.com). |
| 23 | + |
| 24 | +1. Navigate to your Azure Container Registry. |
| 25 | + |
| 26 | +2. In the side **Menu**, under the **Services**, select **Cache** (Preview). |
| 27 | + |
| 28 | + |
| 29 | + :::image type="content" source="./media/container-registry-registry-cache/cache-preview-01.png" alt-text="Screenshot for Registry cache preview."::: |
| 30 | + |
| 31 | + |
| 32 | +3. Select **Create Rule**. |
| 33 | + |
| 34 | + |
| 35 | + :::image type="content" source="./media/container-registry-registry-cache/cache-blade-02.png" alt-text="Screenshot for Create Rule."::: |
| 36 | + |
| 37 | + |
| 38 | +4. A window for **New cache rule** appears. |
| 39 | + |
| 40 | + |
| 41 | + :::image type="content" source="./media/container-registry-registry-cache/new-cache-rule-auth-03.png" alt-text="Screenshot for new Cache Rule."::: |
| 42 | + |
| 43 | + |
| 44 | +5. Enter the **Rule name**. |
| 45 | + |
| 46 | +6. Select **Source** Registry from the dropdown menu. Currently, Caching for ACR only supports **Docker Hub** and **Microsoft Artifact Registry**. |
| 47 | + |
| 48 | +7. Enter the **Repository Path** to the artifacts you want to cache. |
| 49 | + |
| 50 | +8. For adding authentication to the repository, check the **Authentication** box. |
| 51 | + |
| 52 | +9. Choose **Create new credentials** to create a new set of credentials to store the username and password for your source registry. Learn how to [create new credentials](tutorial-enable-registry-cache-auth.md#create-new-credentials) |
| 53 | + |
| 54 | +10. If you have the credentials ready, **Select credentials** from the drop-down menu. |
| 55 | + |
| 56 | +11. Under the **Destination**, Enter the name of the **New ACR Repository Namespace** to store cached artifacts. |
| 57 | + |
| 58 | + |
| 59 | + :::image type="content" source="./media/container-registry-registry-cache/save-cache-rule-04.png" alt-text="Screenshot to save Cache Rule."::: |
| 60 | + |
| 61 | + |
| 62 | +12. Select on **Save** |
| 63 | + |
| 64 | +13. Run the [az keyvault set-policy][az-keyvault-set-policy] command to assign access to the Key Vault, before pulling the image. |
| 65 | + |
| 66 | +```azurecli-interactive |
| 67 | +az keyvault set-policy --name myKeyVaultName --object-id myObjID --secret-permissions get |
| 68 | +``` |
| 69 | + |
| 70 | +14. Pull the image from your cache using the Docker command `docker pull myregistry.azurecr.io/hello-world` |
| 71 | + |
| 72 | +### Create new credentials |
| 73 | + |
| 74 | +1. Navigate to **Credentials** > **Add credential set** > **Create new credentials**. |
| 75 | + |
| 76 | + |
| 77 | + :::image type="content" source="./media/container-registry-registry-cache/add-credential-set-05.png" alt-text="Screenshot for adding credential set."::: |
| 78 | + |
| 79 | + |
| 80 | + :::image type="content" source="./media/container-registry-registry-cache/create-credential-set-06.png" alt-text="Screenshot for create new credential set."::: |
| 81 | + |
| 82 | + |
| 83 | +1. Enter **Name** for the new credentials for your source registry. |
| 84 | + |
| 85 | +1. Select a **Source Authentication**. Caching for ACR currently supports **Select from Key Vault** and **Enter secret URI's**. |
| 86 | + |
| 87 | +1. For the **Select from Key Vault** option, Learn more about [creating credentials using key vault][create-and-store-keyvault-credentials]. |
| 88 | + |
| 89 | +1. Select on **Create** |
| 90 | + |
| 91 | +## Next steps |
| 92 | + |
| 93 | +* Advance to the [next article](tutorial-troubleshoot-registry-cache.md) to walk through the troubleshoot guide for Registry Cache. |
| 94 | + |
| 95 | +<!-- 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 |
0 commit comments