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.

A Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. In 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.

githubusercontent prefix template deployment issue

We can follow the directions below to deploy template on Azure China 21Vianet:

  1. 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 or main (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.

  2. Copy the converted URI and download the specific template content in Internet browsers manully.

  3. Select Build your own template in the editor in the Custom deployment page of portal.

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

  5. Select save to return the Custom deployment page.

  6. Select Review + create.

Button to deploy the Resource Manager template to Azure.

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:

More Azure Container Registry template samples can be found in the quickstart template gallery.

Deploy the template

  1. Select the following image to sign in to Azure and open a template.

    Button to deploy the Resource Manager template to Azure.

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

      Template properties

  3. Select Review + Create, then review the terms and conditions. If you agree, select Create.

  4. After the registry has been created successfully, you get a notification:

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

  1. In the portal, search for Container Registries, and select the container registry you created.

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

    Registry overview

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

    Registry replications

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.

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: