With Azure Container Registry (ACR), we can use geo replications to deploy the service as close as possible to team members and regional application deployments. Azure Traffic Manager will route requests to the closes replication behind the scenes. Artifacts stored in the ACR instance will be synched between all geo replications automatically. I advise customers to use geo replications to
- increase resilience (region outage will have no effect, services and users can consume container images from another geo-replication)
- optimize container boot time in cross-region deployments (pull operations will be faster)
- reduce costs for traffic (egress traffic to other regions)
To use geo replication in ACR, the Premium SKU is required. You’ll be charged with the ACR service fee per geo replication.
Create an ACR instance
Let’s quickly spin up a new instance of Azure Container Registry:
# create a resource group
az group create -n rg-acr-unleashed -l germanywestcentral
# create an ACR instance
az acr create -n unleashed -g rg-acr-unleashed -l germanywestcentral --sku Premium --admin-enabled false
Create new ACR geo replications with Azure CLI
We can add new replications to an ACR instance using the az acr replication create
command.
# create a new geo replication in eastus2
az acr replication create --registry unleashed \
--name unleashedeastus2 \
--location eastus2
By default, endpoints of every geo-replication are enabled, meaning that Azure Traffic Manager will route requests to the closest geo-replication available. However, you can also disable all endpoints for a particular replication. Also, with disabled endpoints, ACR will sync images and artifacts to that particular geo-replication.
To create a new replication with endpoints disabled, set --region-endpoint-enabled
to false
:
# Create another replication but disable endpoints
az acr replication create --registry unleashed \
--name unleashedindia \
--location southindia \
--region-endpoint-enabled false
Modify existing ACR geo replications with Azure CLI
You can update any geo-replication to change the endpoint configuration or update its tags. For demonstration purposes, we’ll activate the endpoints for the replication we created previously (unleashedindia
):
# Modify a replication
az acr replication update --registry unleashed \
--name unleashedindia \
--region-endpoint-enabled true
If we check back for all replications, we see the change being processed:
# List all replications
az acr replication list --registry unleashed \
-o table \
--query '[].{Name:name,Location:location,Status:status.displayStatus,EndpointEnabled:regionEndpointEnabled}'
Name Location Status EndpointEnabled
------------------ ------------------ -------- -----------------
southindia southindia Ready True
germanywestcentral germanywestcentral Ready True
eastus2 eastus2 Ready True
Delete ACR geo replications with Azure CLI
You can also delete existing geo replications using Azure CLI. Use the az acr replication delete
command as shown here:
# delete the eastus2 replication
az acr replication delete --registry unleashed \
--name eastus2