Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 696a8e6

Browse files
committedJun 8, 2021
scaffold
1 parent 4ba7872 commit 696a8e6

File tree

3 files changed

+156
-0
lines changed

3 files changed

+156
-0
lines changed
 
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
---
2+
title: Move Azure container registry to another region
3+
description: Manually move Azure container registry settings and data to another Azure region.
4+
ms.topic: article
5+
ms.date: 06/03/2021
6+
---
7+
8+
# Manually move a container registry to another region
9+
10+
You might need to move an Azure container registry from one Azure region to another. For example, you might want to move your registry to a region used for a development pipeline or a deployment target.
11+
12+
While [Azure Resource Mover](../resource-mover/overview.md) can't currently automate a move for an Azure container registry, you can manually move a container registry to a different region:
13+
14+
* Export a Resource Manager template containing registry settings from a source registry
15+
* Use the template to deploy the target registry in a different Azure region.
16+
* Import registry content from the source registry to the target registry
17+
18+
19+
[!INCLUDE [container-registry-geo-replication-include](../../includes/container-registry-geo-replication-include.md)]
20+
21+
## Prerequisites
22+
23+
Azure CLI
24+
25+
[!INCLUDE [azure-cli-prepare-your-environment-no-header.md](../../includes/azure-cli-prepare-your-environment-no-header.md)]
26+
27+
## Scenario
28+
29+
* The source registry can be in the same or a different Azure subscription or Active Directory tenant as the target registry. Steps in this article show moving the registry within the same subscription.
30+
* Certain registry properties may need to be modified in the deployment template used to move the registry: encryption with a customer-managed key, managed identities, private endpoints (?)
31+
32+
## Export template from source registry
33+
34+
Use the Azure portal, Azure CLI, Azure PowerShell, or other Azure tools to export a resource manager template. To use the Azure portal:
35+
36+
1. In the [Azure portal](https://portal.azure.com), navigate to your source registry.
37+
1. In the menu, under **Automation**, select **Export template** > **Download**.
38+
39+
:::image type="content" source="media/manual-regional-move/export-template.png" alt-text="Export template for container registry":::
40+
41+
## Redeploy target registry in new region
42+
43+
### Modify template
44+
45+
Inspect the registry properties in the exported template JSON file, and make necessary changes. At a minimum, update:
46+
47+
* The registry name `defaultValue` to the desired name of the target registry
48+
* The `location` to desired Azure region for the target registry
49+
50+
```json
51+
{
52+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
53+
"contentVersion": "1.0.0.0",
54+
"parameters": {
55+
"registries_myregistry_name": {
56+
"defaultValue": "myregistry",
57+
"type": "String"
58+
}
59+
},
60+
"variables": {},
61+
"resources": [
62+
{
63+
"type": "Microsoft.ContainerRegistry/registries",
64+
"apiVersion": "2020-11-01-preview",
65+
"name": "[parameters('myregistry_name')]",
66+
"location": "centralus",
67+
[...]
68+
```
69+
70+
### Create resource group
71+
72+
Create a resource group for the target registry using the [az group create](/cli/azure/group#az_group_create). The following example creates a resource group named *myResourceGroup* in the *eastus* location.
73+
74+
```azurecli
75+
az group create --name myResourceGroup --location eastus
76+
```
77+
78+
### Deploy target registry in new region
79+
80+
Use the [az deployment group create](/cli/azure/deployment/group#az_deployment_group_create) command to deploy the target registry, using the template exported from the source registry:
81+
82+
```azurecli
83+
az deployment group --resource-group myResourceGroup \
84+
--template-file template.json --name mydeployment
85+
```
86+
87+
## Import registry content in target registry
88+
89+
Use the [az acr import](/cli/azure/acr#az_acr_import) command to import images and other artifacts you want to keep from the source registry to the target registry. For command examples, see [Import container images to a container registry](container-registry-import-images.md).
90+
91+
* Use the Azure CLI commands [az acr repository list](/cli/azure/acr/repository#az_acr_repository_list) and [az acr repository show-tags](/cli/azure/acr/repository#az_acr_repository_show_tags), or Azure PowerShell equivalents, to help enumerate the contents of your source registry.
92+
* Run the `az acr import` command for individual artifacts, or script it to run over a list of artifacts.
93+
94+
95+
The following sample Azure CLI script enumerates the source repositories and tags and then imports the artifacts to a target registy. Modify as needed to import specific repositories or tags.
96+
97+
```azurecli
98+
#!/bin/bash
99+
# Modify registry names for your environment
100+
SOURCE_REG=mysourceregistry
101+
TARGET_REG=mytargetregistry
102+
103+
# Get list of source repositories
104+
REPO_ARRAY=$(az acr repository list --name $SOURCE_REG --output tsv)
105+
106+
# Enumerate tags and import to target registry
107+
for repo in $REPO_ARRAY; do
108+
TAGS_ARRAY=$(az acr repository show-tags --name $SOURCE_REG --repository $repo --output tsv);
109+
for tag in $TAGS_ARRAY; do
110+
echo "Importing $repo:$tag";
111+
az acr import --name $TARGET_REG --source $SOURCE_REG.azurecr.io/$repo":"$tag;
112+
done
113+
done
114+
```
115+
116+
117+
For an Azure PowerShell script to import a list of artifacts from a source registry to a target registry, see [Link to Matt's script]
118+
119+
## Verify target registry
120+
121+
Confirm the following information in your target registry:
122+
123+
* Registry settings such as the registry name, service tier, public access, and replications
124+
* Repositories and tags for content that you want to move.
125+
126+
### Additional configuration
127+
128+
* Manually configure registry settings that weren't created during the deployment of the target registry, including:
129+
130+
* Registry encryption settings
131+
* User-assigned and system-assigned identities
132+
* Private endpoints
133+
134+
* Update development and deployment systems to use the target registy instead of the source registry.
135+
136+
## Delete original registry
137+
138+
After you have successfully deployed the target registry, migrated content, and verified development and deployment settings, you may delete the source registry, if it is no longer in use.
139+
140+
## Next steps
141+
142+
* Learn more about [importing container images](container-registry-import-images.md) to an Azure container registry from a public registry or another private registry.
143+
144+
<!-- LINKS - Internal -->
145+
[az-login]: /cli/azure/reference-index#az_login
146+
[az-acr-import]: /cli/azure/acr#az_acr_import
147+
[azure-cli]: /cli/azure/install-azure-cli
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
author: dlepow
3+
ms.service: container-registry
4+
ms.topic: include
5+
ms.date: 06/07/2021
6+
ms.author: danlep
7+
---
8+
> [!NOTE]
9+
> If you need to distribute identical container images across multiple Azure regions, Azure Container Registry also supports [geo-replication](../articles/container-registry/container-registry-geo-replication.md). By geo-replicating a registry (Premium service tier required), you can serve multiple regions with identical image and tag names from a single registry.

0 commit comments

Comments
 (0)
Please sign in to comment.