Versioning and Managing Images in ACR
This lesson explains tagging strategies and the registry features that protect, clean up, import and replicate images.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish stable tags from unique tags.
- Describe how image locking protects releases.
- Explain retention policies and acr purge.
- Describe geo-replication and image import.
Tagging strategies
Microsoft describes two complementary tagging strategies, and most teams use both. Stable tags are reused for a line of images: a base image tagged python-base:3.12 is rebuilt and pushed with the same tag whenever a security patch arrives, so that anything built on it picks up the patch. Stable tags are what downstream builds should reference, because they are meant to change in controlled ways.
Unique tags are never reused. Common choices are the build ID, the date and time, or the Git commit hash, such as orders-api:20261102.4 or orders-api:7f3c2ab. Deployments should reference unique tags, because every environment then runs a known image, a rollback is a change of tag, and logs and traces can be matched to the exact source code. A semantic version such as 1.4.2 is a unique tag only if the team guarantees never to push it twice.
python-base:3.12orders-api:7f3c2abStable or unique tag?
Locking images
Even with unique tags, someone can push a new image with an existing tag or delete a production image by mistake. ACR lets you set attributes on a repository, a tag or a manifest: write-enabled controls whether it can be overwritten, delete-enabled controls whether it can be deleted, and read-enabled and list-enabled control whether it can be pulled and listed. Setting write-enabled and delete-enabled to false locks a released image.
az acr repository update --name REGISTRY --image orders-api:1.4.2 \
--write-enabled false --delete-enabled falseA locked tag cannot be moved to a new image, which protects a release from accidental replacement. Locking is applied per image or per repository and can be reversed by someone with sufficient rights, so it complements rather than replaces role-based access control.
Untagged manifests, retention and purging
When a tag is moved to a new image, the old manifest stays in the registry without a tag. These untagged (or dangling) manifests consume storage and are rarely needed. ACR can remove them in several ways, and the right one depends on how aggressive the clean-up should be.
- A retention policy for untagged manifests, a Premium feature in preview, deletes untagged manifests automatically after a set number of days.
- The
acr purgecommand, run on demand or on a schedule as an ACR task, deletes images older than a given age whose tags match a filter, and can also remove untagged manifests. az acr repository deletedeletes a specific image or a whole repository. Deleting by digest removes the manifest and every tag that points to it.
The following example runs acr purge as a scheduled task every day at 01:00 UTC, deleting images in the orders-api repository that are older than 30 days, together with untagged manifests. Locked images are skipped.
az acr task create --registry REGISTRY --name purge-old-images \
--cmd "acr purge --filter 'orders-api:.*' --ago 30d --untagged" \
--schedule "0 1 * * *" --context /dev/nullThe following diagram shows two measures that together protect released images and control storage in a large registry: locking released images and purging old ones on a schedule.

Cleaning up a registry
Importing and replicating images
az acr import copies an image from another registry, such as Docker Hub, Microsoft Artifact Registry or another ACR, directly into your registry without pulling it to a client. Importing base images into your own registry protects builds from public registry rate limits and outages, and lets you scan and approve them before use.
Geo-replication, a Premium feature, turns one registry into a single registry with replicas in several regions. Hosts in each region pull from the nearest replica through the same login server name, which reduces latency and cross-region data transfer, and the registry keeps serving pulls if one region has an outage. Pushes to any replica are replicated to the others. Geo-replication is different from simply creating several registries, which would require pipelines to push to each and hosts to use different names.
Import and geo-replication
Protecting releases and controlling storage
A registry holds 4,000 images, most of them untagged leftovers from development builds, and storage costs are rising. Released images tagged release-* must never be overwritten or deleted. The team wants the clean-up to run without manual work.
Two measures meet the requirements. First, lock each released image by setting write-enabled and delete-enabled to false when it is promoted. Second, create a scheduled ACR task that runs acr purge with a filter for development tags and the --untagged option, which removes old development images and dangling manifests; locked images are skipped automatically.
Deleting the repository and pushing release images again would lose history and break running deployments. A retention policy alone would remove only untagged manifests, not old tagged development images, and it requires the Premium tier.
Which image attributes do you set to stop a released image from being overwritten or deleted?
Show answer
Set write-enabled and delete-enabled to false with az acr repository update. This locks the image, and acr purge skips locked images.
Exam Tips
Remember for the exam
- Base images use stable tags; deployed application images use unique tags.
- Lock released images with write-enabled and delete-enabled set to false.
- acr purge in a scheduled task cleans up old and untagged images; locked images are skipped.
- Geo-replication keeps one login server with replicas in several regions (Premium).