4.1.6.6. Create and Manage an Azure Container Registry
4.1.6.6. Create and Manage an Azure Container Registry
💡 First Principle: Every container service in Azure starts by pulling an image, so the registry is the supply chain for all of them. Choosing a registry tier is mostly about which network and resilience features you need, and granting access is about giving each puller or pusher its own identity with the narrowest role.
Scenario: A platform team builds images for an orders API. A CI pipeline must push new versions, while Azure Container Apps and Azure Container Instances in two regions only need to pull them. Security wants the registry reachable only through private endpoints, and nobody wants a shared password stored in pipeline variables.
What It Is: Azure Container Registry is a managed, private registry for Docker and OCI images and other artifacts. Each registry has a login server named <registry-name>.azurecr.io. The name must be globally unique and use 5 to 50 lowercase alphanumeric characters.
Service Tiers (SKU features and limits)
| Capability | Basic | Standard | Premium |
|---|---|---|---|
| Included storage | 10 GiB | 100 GiB | 500 GiB |
| Webhooks | 2 | 10 | 500 |
| Availability zones (zone redundancy) | Yes | Yes | Yes |
| Anonymous pull, artifact cache | No | Yes | Yes |
| Geo-replication | No | No | Yes |
| Private link with private endpoints, IP access rules | No | No | Yes |
| Customer-managed keys | No | No | Yes |
| Connected registries, dedicated agent pools for Tasks | No | No | Yes |
All tiers share the same APIs and support Microsoft Entra authentication and webhooks. You can change tiers at any time with no downtime, either in Properties > Pricing plan or with az acr update --sku. Moving down from Premium disables its features, and you must first delete any geo-replications or connected registries.
Authentication Options
| Method | How | Typical use | Notes |
|---|---|---|---|
| Individual Microsoft Entra identity | az acr login | A developer pushing or pulling interactively | The token lasts 3 hours; the Docker daemon must be running, or use --expose-token |
| Service principal | docker login or az acr login | Unattended push from CI/CD, pulls from external systems | Azure RBAC role on the registry |
| Managed identity | Configured on the Azure service | Pulls by Azure services such as Container Apps and Container Instances | No secret to store or rotate |
| Admin user | docker login with the admin password | Testing, some portal deployments | Disabled by default; one account per registry with two passwords; always full push and pull rights |
Roles for Pushing and Pulling
New registries use the RBAC Registry Permissions mode by default. In that mode:
- AcrPull lets an identity pull images. Give it to anything that only runs containers.
- AcrPush lets an identity push and pull. Give it to build pipelines.
- AcrDelete lets an identity delete images and tags.
A registry switched to RBAC Registry + ABAC Repository Permissions mode doesn't honor AcrPull, AcrPush, or AcrDelete. It uses Container Registry Repository Reader, Writer, and Contributor instead, which can be scoped to individual repositories with conditions.
Building Images with ACR Tasks
az acr build runs a quick task: it uploads your build context, builds the image in Azure from your Dockerfile, and pushes the result to the registry. You don't need Docker installed locally. ACR Tasks can also rebuild automatically on source commits or base image updates.
Pulling from Azure Container Instances and Azure Container Apps
- Container Instances supports managed identity pulls only with a user-assigned identity; system-assigned identity isn't supported for ACR image pulls. Grant the identity AcrPull, then pass it with
--acr-identityand--assign-identity. - Container Apps supports system-assigned or user-assigned identities (Microsoft recommends user-assigned). The CLI can add the AcrPull assignment for you.
- Microsoft's authentication guidance notes that some portal deployments of a registry image straight to Container Instances or Container Apps still require the admin user. Outside that case, prefer identities. AKS integration is covered in 4.1.6.4.
Practical Implementation: Create, Build, and Grant Pull Access with Azure CLI
# Create a Premium registry (needed for private endpoints and geo-replication)
az acr create --resource-group rg-platform --name contosoplatform --sku Premium
# Sign in as yourself and build in the cloud; the image is pushed when the build succeeds
az acr login --name contosoplatform
az acr build --registry contosoplatform --image orders-api:1.4.2 .
# Give a user-assigned managed identity pull-only rights on the registry
ACR_ID=$(az acr show --name contosoplatform --query id --output tsv)
az role assignment create --assignee <identity-principal-id> --role AcrPull --scope $ACR_ID
# Container Instances pulls with that user-assigned identity
az container create --resource-group rg-apps --name orders-aci \
--image contosoplatform.azurecr.io/orders-api:1.4.2 \
--acr-identity <identity-resource-id> --assign-identity <identity-resource-id> --ports 80
⚠️ Common Pitfall: Enabling the admin user so every pipeline and app can share one username and password. All of those callers appear as a single identity with push rights, and rotating the password breaks every one of them at once. Use AcrPush for pipelines and AcrPull through managed identities for workloads.
⚠️ Exam Trap: When a requirement mentions replicating images to several regions, private endpoints, or customer-managed keys, only Premium satisfies it; Standard adds storage and throughput, not these features. And when a Container Instances group must pull with a managed identity, a system-assigned identity won't work: it must be user-assigned.
Key Trade-Offs:
- Standard vs. Premium: Standard covers most single-region production registries at lower cost. Premium is required once the registry must be private or geo-replicated.
- Managed identity vs. service principal: A managed identity needs no secret but works only from Azure services that support it. A service principal works from anywhere, including external CI systems, but its credential expires and must be rotated.
Reflection Question: A pipeline pushes images with the admin password and three apps pull with the same password. How would you replace this with identities and roles, and which tier, if any, would you need to change?