Enable Artifact Cache - Azure CLI
This article is part two of a tutorial series. Part one provides an overview of Artifact Cache, its features, benefits, and limitations. This article walks you through the steps of enabling Artifact Cache by using the Azure CLI without authentication.
Prerequisites
- You can use the local installation of the Azure CLI to run the command examples in this article. If you'd like to use it locally, version 2.46.0 or later is required. Run
az --version
to find the version. If you need to install or upgrade, see Install Azure CLI.
Configure Artifact Cache - Azure CLI
Follow the steps to create a Cache rule without using the Credentials.
Create a Cache rule
Run az acr Cache create command to create a Cache rule.
- For example, to create a Cache rule without the credentials for a given
MyRegistry
Azure Container Registry.
az acr Cache create -r MyRegistry -n MyRule -s docker.io/library/ubuntu -t ubuntu
- For example, to create a Cache rule without the credentials for a given
Run az acr Cache show command to show a Cache rule.
- For example, to show a Cache rule for a given
MyRegistry
Azure Container Registry.
az acr Cache show -r MyRegistry -n MyRule
- For example, to show a Cache rule for a given
Pull your image
Pull the image from your cache using the Docker command by the registry login server name, repository name, and its desired tag.
- For example, to pull the image from the repository
hello-world
with its desired taglatest
for a given registry login servermyregistry.azurecr.cn
.
docker pull myregistry.azurecr.cn/hello-world:latest
- For example, to pull the image from the repository
Clean up the resources
Run az acr Cache list command to list the Cache rules in the Azure Container Registry.
- For example, to list the Cache rules for a given
MyRegistry
Azure Container Registry.
az acr Cache list -r MyRegistry
- For example, to list the Cache rules for a given
Run az acr Cache delete command to delete a Cache rule.
- For example, to delete a Cache rule for a given
MyRegistry
Azure Container Registry.
az acr Cache delete -r MyRegistry -n MyRule
- For example, to delete a Cache rule for a given
Next steps
- To enable Artifact Cache with authentication using the Azure CLI advance to the next article Enable Artifact Cache - Azure CLI.