Lesson 3 of 3 Container Images and Azure Container Registry

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.

Stable tag
Examplepython-base:3.12
ReusedYes, for each patched rebuild
Best forBase images and framework images
RiskA host may pull a different image after a restart
Choose when Downstream builds should receive patches
Unique tag
Exampleorders-api:7f3c2ab
ReusedNever
Best forApplication images that are deployed
RiskMany tags accumulate and need cleaning up
Choose when A deployment must be repeatable and traceable
Sort into groups

Stable or unique tag?

Exam skills 1.1.1

Decide which kind of tag each image should use.

Log in to try this activity Interactive activities are free with an account.

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 false

A 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 purge command, 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 delete deletes 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/null

The 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.

Two measures for a large registry. Each released image is locked when it is promoted by setting write-enabled and delete-enabled to false. A scheduled ACR task runs acr purge with a filter for development tags and the --untagged option, removing old development images and dangling manifests; locked images are skipped automatically.
Purge never removes a locked image.
Scenario questions

Cleaning up a registry

Exam skills 1.1.1

Choose the clean-up method that fits each situation.

Log in to try this activity Interactive activities are free with an account.

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.

Select all that apply

Import and geo-replication

Exam skills 1.1.1

Identify the true statements about importing and replicating images.

Log in to try this activity Interactive activities are free with an account.
Worked example

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.

Check yourself

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).