Skip to content

Commit 4bc4b1c

Browse files
committed
work in progress
1 parent cd2643c commit 4bc4b1c

File tree

1 file changed

+75
-30
lines changed

1 file changed

+75
-30
lines changed

articles/container-registry/container-registry-transfer-images.md

Lines changed: 75 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
11
---
22
title: Transfer images
3-
description: You learn how to ...
3+
description: Transfer images in bulk from one container registry to another registry by creating a transfer pipeline using Azure storage accounts
44
ms.topic: article
55
ms.date: 03/31/2020
66
ms.custom:
77
---
88

99
# Transfer images to another registry
1010

11-
[Intro]
11+
This article shows how to transfer images or other registry artifacts in bulk from one Azure container registry to another registry. The source and target registries can be in the same or different subscriptions, or potentially in different Active Directory tenants or Azure clouds.
1212

13-
If you'd like to use the Azure CLI locally, you must have Azure CLI version **XXX** or later installed and logged in with [az login][az-login]. Run `az --version` to find the version. If you need to install or upgrade the CLI, see [Install Azure CLI][azure-cli].
13+
To transfer images, you create a transfer *pipeline*:
14+
15+
* Create source and target storage resources, and store storage access secrets in Azure key vaults
16+
* Create and run a registry resource to export images to the source storage account
17+
* Copy images from the source storage account to the target storage account
18+
* Create a registry resource to import images to the target registry. You can set up the import pipeline to trigger whenever images are in the source storage account
19+
20+
Transferring registry images offers a more general, scalable alternative to [importing images](container-registry-import-images.md) from one container registry to another.
21+
22+
In this article, you use the Azure CLI and Azure Resource Manager templates to create the resources and transfer pipeline. If you'd like to use the Azure CLI locally, you must have Azure CLI version **XXX** or later installed and logged in with [az login][az-login]. Run `az --version` to find the version. If you need to install or upgrade the CLI, see [Install Azure CLI][azure-cli].
23+
24+
This feature is available in the **Premium** container registry service tier. For information about registry service tiers and limits, see [Azure Container Registry SKUs](container-registry-skus.md).
1425

1526

1627
## Prerequisites
1728

18-
* **Storage accounts** - Create source and target storage accounts. If needed, create the storage accounts with the [Azure CLI](../storage/common/storage-account-create.md?tabs=azure-cli) or other tools. The source and target storage accounts can be in the same or a different Azure subscription. For the steps in article, the accounts must be in the same Active Directory tenant.
19-
* **Key vault** for storing secrets - If needed, create a key vault with the [Azure CLI](../key-vault/quick-create-cli.md) or other tools
2029
* **Container registries** - For this scenario you need an existing source registry with images to transfer, and a target registry. The source and target registry can be in the same or a different Azure subscription. For the steps in article, the registries must be in the same Active Directory tenant. If you need to create a registry, see [Quickstart: Create a private container registry using the Azure CLI](container-registry-get-started-cli.md).
30+
* **Storage accounts** - Create source and target storage accounts in the same Azure subscriptions as your source and target registries. If needed, create the storage accounts with the [Azure CLI](../storage/common/storage-account-create.md?tabs=azure-cli) or other tools.
31+
32+
[TODO: Needed to create source and target blob containers??]
33+
34+
* **Key vaults** Create key vaults to store secrets in the same Azure subscriptions as your source and target registries. If needed, create source and target key vaults with the [Azure CLI](../key-vault/quick-create-cli.md) or other tools.
2135

2236
## Scenario overview
2337

24-
The following three resources are used for ACR Transfer. All are created using PUT operations.
38+
You create the following three resources for ACR Transfer. All are created using PUT operations.
2539

26-
* **ExportPipeline** - Long lasting resource that contains high level target info, such as storage blob container URI and the KV secret URI of the target storage SAS token.
40+
* **ExportPipeline** - Long-lasting resource that contains high level target information, such as storage blob container URI and the key vault secret URI of the target storage SAS token.
2741
* **ImportPipeline** - Long lasting resource that contains high level source info, such as storage blob container URI and the KV secret URI of the source storage SAS token. Source trigger is enabled by default so the pipeline will run automatically when artifacts land in the source storage container.
2842
* **PipelineRun** Resource used to invoke either an ExportPipeline or ImportPipeline resource.
2943

30-
An ExportPipeline must be run manualIly by creating a PipelineRun resource. When you run the ExportPipeline, you specify the artifacts to be exported.
44+
An ExportPipeline must be run manually by creating a PipelineRun resource. When you run the ExportPipeline, you specify the artifacts to be exported.
3145

32-
An ImportPipeline configured with source trigger enabled is run automatically. It can also be run manually using a PipelineRun.
33-
34-
### Assumptions for this article
35-
* The export and import SAS tokens are located in the same key vault, and a user-assigned identity is shared between export and import.
36-
* The source and target registries and storage accounts are in the same tenant.
46+
If a source trigger is enabled, an ImportPipeline runs automatically. It can also be run manually using a PipelineRun.
3747

3848
### Alternate scenarios
3949
* The ImportPipeline and ExportPipeline may be located in different tenants. In this case, you need separate managed identities and key vaults for the export and import resources.
@@ -43,6 +53,8 @@ An ImportPipeline configured with source trigger enabled is run automatically. I
4353

4454
Transfer uses shared access signature (SAS) tokens to export to and import from storage accounts. The properties required to create SAS tokens are detailed below.
4555

56+
[TODO: Create containers, generate tokens at container level?]
57+
4658
### SAS token for export
4759

4860
Generate a SAS token for export in the source storage account.
@@ -62,13 +74,13 @@ Copy the generated SAS token and use it to set the EXPORT_SAS environment variab
6274
EXPORT_SAS='?sv=2019-02-02&...'
6375
```
6476

65-
Store the SAS token in your Azure key vault using [az keyvault secret set][az-keyvault-secret-set]:
77+
Store the SAS token in your source Azure key vault using [az keyvault secret set][az-keyvault-secret-set]:
6678

6779
```azurecli
6880
az keyvault secret set \
6981
--name acrexportsas \
7082
--value $EXPORT_SAS \
71-
--vault-name mykeyvault
83+
--vault-name sourcekeyvault
7284
```
7385

7486
### SAS token for import
@@ -89,44 +101,65 @@ Copy the generated SAS token and use it to set the IMPORT_SAS environment variab
89101
```console
90102
IMPORT_SAS='?sv=2019-02-02&...'
91103

92-
Store the SAS token in your Azure key vault using [az keyvault secret set][az-keyvault-secret-set]:
104+
Store the SAS token in your target Azure key vault using [az keyvault secret set][az-keyvault-secret-set]:
93105

94106
```azurecli
95107
az keyvault secret set \
96108
--name acrimportsas \
97109
--value $IMPORT_SAS \
98-
--vault-name mykeyvault
110+
--vault-name targetkeyvault
99111
```
100112

101-
## Create identity
113+
## Create identities
114+
115+
Create user-assigned managed identities for source and target key vaults by running the [az identity create][az-identity-create] command.
102116

103-
Create the user-assigned managed identity by running the [az identity create][az-identity-create] command.
104117

105-
106118
```azurecli
119+
# Managed identity for source vault
107120
az identity create \
108121
--resource-group myResourceGroup \
109-
--name myPipelineId
122+
--name sourceId
123+
124+
# Managed identity for target vault
125+
az identity create \
126+
--resource-group myResourceGroup \
127+
--name targetId
110128
```
111129

112130
Set the following variables using the [az identity show][az-identity-show] command:
113131

114132
```azurecli
115-
principalID=$(az identity show \
133+
sourcePrincipalID=$(az identity show \
116134
--resource-group myResourceGroup \
117-
--name myPipelineId --query principalId --output tsv)
135+
--name sourceId --query principalId --output tsv)
118136
119-
resourceID=$(az identity show \
137+
sourceResourceID=$(az identity show \
138+
--resource-group myResourceGroup \
139+
--name myPipelineId --query id --output tsv)
140+
141+
targetPrincipalID=$(az identity show \
142+
--resource-group myResourceGroup \
143+
--name sourceId --query principalId --output tsv)
144+
145+
targetResourceID=$(az identity show \
120146
--resource-group myResourceGroup \
121147
--name myPipelineId --query id --output tsv)
122148
```
123149

124-
## Grant the identity access to key vault
150+
## Grant each identity access to key vault
125151

126-
Run the [az keyvault set-policy][az-keyvault-set-policy] command to grant the identity access to your key vault:
152+
Run the [az keyvault set-policy][az-keyvault-set-policy] command to grant each identity access to the respective key vault:
127153

128154
```azurecli
129-
az keyvault set-policy --name mykeyvault \
155+
# Source key vault
156+
az keyvault set-policy --name sourcekeyvault \
157+
--resource-group myResourceGroup \
158+
--object-id $principalID \
159+
--secret-permissions get
160+
161+
# Target key vault
162+
az keyvault set-policy --name targetkeyvault \
130163
--resource-group myResourceGroup \
131164
--object-id $principalID \
132165
--secret-permissions get
@@ -154,6 +187,8 @@ az deployment group create \
154187

155188
Copy ExportPipeline Resource Manager template files from [here](add link - TBD).
156189

190+
[Create a list of images to transfer - what is format?]
191+
157192
Run [az deployment group create][az-deployment-group-create] to run the resource.
158193

159194
```azurecli
@@ -163,13 +198,20 @@ az group deployment create \
163198
--parameters azuredeploy.parameters.json
164199
```
165200

166-
[How to specify the artifacts?]
167-
168201
## Transfer blob (optional)
169202

170203
Copy the blob to the target storage account using the AzCopy command. See [Copy blobs between storage accounts](/storage/common/storage-use-azcopy-blobs.md#copy-blobs-between-storage-accounts).
171204

172-
[What does the AzCopy command look like?]
205+
[TODO: What does the AzCopy command look like? Is it the `azcopy sync` shown below?]
206+
207+
Synchronize the source and target storage containers:
208+
209+
```console
210+
azcopy sync \
211+
'https://<source-storage-account-name>.blob.core.windows.net/<container-name>' \
212+
'https://<destination-storage-account-name>.blob.core.windows.net/<container-name>' \
213+
--recursive
214+
```
173215

174216
## Import
175217

@@ -202,6 +244,9 @@ az group deployment create \
202244
--parameters azuredeploy.parameters.json
203245
```
204246

247+
## Verify image transfer
248+
249+
[TODO]
205250

206251
<!-- LINKS - External -->
207252

0 commit comments

Comments
 (0)