Quickstart: Create a geo-replicated container registry by using an ARM template
This quickstart shows how to create an Azure Container Registry instance by using an Azure Resource Manager template (ARM template). The template sets up a geo-replicated registry, which automatically synchronizes registry content across more than one Azure region. Geo-replication enables network-close access to images from regional deployments, while providing a single management experience. It's a feature of the Premium registry service tier.
An Azure Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. You describe your intended deployment without writing the sequence of programming commands to create the deployment.
The registry with replications does not support the ARM/Bicep template Complete mode deployments.
If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.
Note
When we download the specific template from https://raw.githubusercontent.com/
website and try to deploy with custom template, there will be encounter certain issue sometime.
We can follow the directions below to deploy template on Azure China 21Vianet:
Copy the template URI, convert the URI by changing the prefix, infix, and tempalte file name. For example: the origin URI is
https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.network/vnet-two-subnets/azuredeploy.json
Category Original value Converted value Action Prefix https://raw.githubusercontent.com
https://github.com
Update Infix blob
Add before master
ormain
(default branch name of git repository)Template file name azuredeploy.json keep the default value or replace with new template file name. update After modified, the converted URI will show like
https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.network/vnet-two-subnets/azuredeploy.json
.Please be kindly noticed that many templates have been moved to the path like https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/{Microsoft_Resource_Provider_Name}/, you can follow the corresponding path regulation to update the original URI.
Copy the converted URI and download the specific template content in Internet browsers manully.
Select Build your own template in the editor in the Custom deployment page of portal.
Copy the downloaded template content in the Edit template page and update the parameters to meet Azure China Cloud, such as endpoint, Location, VM images, VM sizes, SKU , and resource-provider's API Version that is not supported on Azure China Cloud environment.
Select save to return the Custom deployment page.
Select Review + create.
Prerequisites
If you don't have an Azure subscription, create a trial subscription account before you begin.
Review the template
The template used in this quickstart is from Azure Quickstart Templates. The template sets up a registry and an additional regional replica.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.5.6.12127",
"templateHash": "12610175857982700190"
}
},
"parameters": {
"acrName": {
"type": "string",
"defaultValue": "[format('acr{0}', uniqueString(resourceGroup().id))]",
"maxLength": 50,
"minLength": 5,
"metadata": {
"description": "Globally unique name of your Azure Container Registry"
}
},
"acrAdminUserEnabled": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Enable admin user that has push / pull permission to the registry."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for registry home replica."
}
},
"acrSku": {
"type": "string",
"defaultValue": "Premium",
"allowedValues": [
"Premium"
],
"metadata": {
"description": "Tier of your Azure Container Registry. Geo-replication requires Premium SKU."
}
},
"acrReplicaLocation": {
"type": "string",
"metadata": {
"description": "Short name for registry replica location."
}
}
},
"resources": [
{
"type": "Microsoft.ContainerRegistry/registries",
"apiVersion": "2019-12-01-preview",
"name": "[parameters('acrName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('acrSku')]"
},
"tags": {
"displayName": "Container Registry",
"container.registry": "[parameters('acrName')]"
},
"properties": {
"adminUserEnabled": "[parameters('acrAdminUserEnabled')]"
}
},
{
"type": "Microsoft.ContainerRegistry/registries/replications",
"apiVersion": "2019-12-01-preview",
"name": "[format('{0}/{1}', parameters('acrName'), parameters('acrReplicaLocation'))]",
"location": "[parameters('acrReplicaLocation')]",
"properties": {},
"dependsOn": [
"[resourceId('Microsoft.ContainerRegistry/registries', parameters('acrName'))]"
]
}
],
"outputs": {
"acrLoginServer": {
"type": "string",
"value": "[reference(resourceId('Microsoft.ContainerRegistry/registries', parameters('acrName'))).loginServer]"
}
}
}
The following resources are defined in the template:
- Microsoft.ContainerRegistry/registries: create an Azure container registry
- Microsoft.ContainerRegistry/registries/replications: create a container registry replica
More Azure Container Registry template samples can be found in the quickstart template gallery.
Deploy the template
Select the following image to sign in to Azure and open a template.
Select or enter the following values.
Subscription: select an Azure subscription.
Resource group: select Create new, enter a unique name for the resource group, and then select OK.
Region: select a location for the resource group. Example: China East 2.
Acr Name: accept the generated name for the registry, or enter a name. It must be globally unique.
Acr Admin User Enabled: accept the default value.
Location: accept the generated location for the registry's home replica, or enter a location such as China East 2.
Acr Sku: accept the default value.
Acr Replica Location: enter a location for the registry replica, using the region's short name. It must be different from the home registry location. Example: chinaeast2.
Select Review + Create, then review the terms and conditions. If you agree, select Create.
After the registry has been created successfully, you get a notification:
The Azure portal is used to deploy the template. In addition to the Azure portal, you can use the Azure PowerShell, Azure CLI, and REST API. To learn other deployment methods, see Deploy templates.
Review deployed resources
Use the Azure portal or a tool such as the Azure CLI to review the properties of the container registry.
In the portal, search for Container Registries, and select the container registry you created.
On the Overview page, note the Login server of the registry. Use this URI when you use Docker to tag and push images to your registry. For information, see Push your first image using the Docker CLI.
On the Replications page, confirm the locations of the home replica and the replica added through the template. If desired, add more replicas on this page.
Clean up resources
When you no longer need them, delete the resource group, the registry, and the registry replica. To do so, go to the Azure portal, select the resource group that contains the registry, and then select Delete resource group.
Next steps
In this quickstart, you created an Azure Container Registry with an ARM template, and configured a registry replica in another location. Continue to the Azure Container Registry tutorials for a deeper look at ACR.
For a step-by-step tutorial that guides you through the process of creating a template, see: