Skip to content

Commit fb663e1

Browse files
committed
rough draft
1 parent 5df577d commit fb663e1

File tree

1 file changed

+93
-31
lines changed

1 file changed

+93
-31
lines changed

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

Lines changed: 93 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Transfer images
33
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
5-
ms.date: 04/03/2020
5+
ms.date: 04/06/2020
66
ms.custom:
77
---
88

@@ -25,19 +25,16 @@ This feature is available in the **Premium** container registry service tier. Fo
2525

2626
## Prerequisites
2727

28-
* **Container registries** - For this scenario you need an existing source registry with images to transfer, and a target registry. The source and target registries can be in the same or a different Azure subscription. The steps in this article assume that the registries are 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).
29-
* **Storage accounts** - Create source and target storage accounts in the same Azure subscription or 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. In each account, create a blob container for image transfer. For example, create a container named *transfer*
28+
* **Container registries** - For this scenario you need an existing source registry with images you want to transfer, and a target registry. The source and target registries can be in the same or a different Azure subscription, Active Directory tenant, or cloud. If you need to create a registry, see [Quickstart: Create a private container registry using the Azure CLI](container-registry-get-started-cli.md).
29+
* **Storage accounts** - Create source and target storage accounts in a subscription and location of your choice. If needed, create the storage accounts with the [Azure CLI](../storage/common/storage-account-create.md?tabs=azure-cli) or other tools. In each account, create a blob container for image transfer. For example, create a container named *transfer*
3030
* **Key vaults** Create key vaults to store secrets in the same Azure subscription or 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.
3131

3232
## Scenario overview
3333

34-
You create the following three resources for ACR Transfer. All are created using PUT operations. These resources operate on two storage accounts:
34+
You create the following three resources for ACR Transfer. All are created using PUT operations. These resources operate on your *source* and *target* registries and storage accounts.
3535

36-
* A *source* storage account, where images from the source registry get exported
37-
* A *target* storage account, from which images are imported to the target registry
38-
39-
* **ExportPipeline** - Long-lasting resource that contains high-level information about the the *source* storage account. This information includes the storage blob container URI and the key vault secret URI of the storage SAS token.
40-
* **ImportPipeline** - Long-lasting resource that contains high-level information about the *target* storage account. This information includes the storage blob container URI and the key vault secret URI of the storage SAS token. An import trigger is enabled by default, so the pipeline runs automatically when artifacts land in the target storage container.
36+
* **ExportPipeline** - Long-lasting resource that contains high-level information about the *source* registry and storage account. This information includes the storage blob container URI and the key vault secret URI of the storage SAS token.
37+
* **ImportPipeline** - Long-lasting resource that contains high-level information about the *target* registry and storage account. This information includes the storage blob container URI and the key vault secret URI of the storage SAS token. An import trigger is enabled by default, so the pipeline runs automatically when artifacts land in the target storage container.
4138
* **PipelineRun** Resource used to invoke either an ExportPipeline or ImportPipeline resource.
4239

4340
You run the ExportPipeline manually by creating a PipelineRun resource. When you run the ExportPipeline, you specify the artifacts to be exported.
@@ -80,6 +77,12 @@ az keyvault secret set \
8077
--vault-name sourcekeyvault
8178
```
8279

80+
In the command output, take note of the secret's URI (`id`). You use the URIs in the export pipelines. Example:
81+
82+
```azurecli
83+
https://sourcekeyvault.vault-int.azure-int.net/secrets/acrexportsas/xxxxxxxxxxxxxxx
84+
```
85+
8386
### SAS token for import
8487

8588
Generate a SAS token for import from the target storage account.
@@ -97,6 +100,7 @@ Copy the generated SAS token and use it to set the IMPORT_SAS environment variab
97100

98101
```console
99102
IMPORT_SAS='?sv=2019-02-02&...'
103+
```
100104

101105
Store the SAS token in your target Azure key vault using [az keyvault secret set][az-keyvault-secret-set] command:
102106

@@ -106,12 +110,16 @@ az keyvault secret set \
106110
--value $IMPORT_SAS \
107111
--vault-name targetkeyvault
108112
```
113+
In the command output, take note of the secret's URI (`id`). You use the URI in the import pipeline. Example:
114+
115+
```azurecli
116+
https://targetkeyvault.vault-int.azure-int.net/secrets/acrimportsas/xxxxxxxxxxxxxxx
117+
```
109118

110119
## Create identities
111120

112121
Create user-assigned managed identities for source and target key vaults by running the [az identity create][az-identity-create] command.
113122

114-
115123
```azurecli
116124
# Managed identity for source vault
117125
az identity create \
@@ -133,15 +141,15 @@ sourcePrincipalID=$(az identity show \
133141
134142
sourceResourceID=$(az identity show \
135143
--resource-group myResourceGroup \
136-
--name myPipelineId --query id --output tsv)
144+
--name sourceId --query id --output tsv)
137145
138146
targetPrincipalID=$(az identity show \
139147
--resource-group myResourceGroup \
140-
--name sourceId --query principalId --output tsv)
148+
--name targetId --query principalId --output tsv)
141149
142150
targetResourceID=$(az identity show \
143151
--resource-group myResourceGroup \
144-
--name myPipelineId --query id --output tsv)
152+
--name targetId --query id --output tsv)
145153
```
146154

147155
## Grant each identity access to key vault
@@ -152,13 +160,13 @@ Run the [az keyvault set-policy][az-keyvault-set-policy] command to grant the so
152160
# Source key vault
153161
az keyvault set-policy --name sourcekeyvault \
154162
--resource-group myResourceGroup \
155-
--object-id $principalID \
163+
--object-id $sourcePrincipalID \
156164
--secret-permissions get
157165
158166
# Target key vault
159167
az keyvault set-policy --name targetkeyvault \
160168
--resource-group myResourceGroup \
161-
--object-id $principalID \
169+
--object-id $targetPrincipalID \
162170
--secret-permissions get
163171
```
164172

@@ -170,6 +178,15 @@ Create an ExportPipeline resource for your source container registry using Azure
170178

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

181+
Enter the following parameter values in the file `azuredeploy.parameters.json`:
182+
183+
|Parameter |Value |
184+
|---------|---------|
185+
|registryName | Name of your source container registry |
186+
|exportPipelineName | Name you choose for the export pipeline |
187+
|targetUri | URI of the container in your source storage account. Example: `https://sourcestorage.blob.core.windows.net/transfer` |
188+
|keyVaultUri | URI of the SAS token secret in the source key vault. Example: `https://sourcevault.vault-int.azure-int.net/secrets/acrexportsas` |
189+
173190
Run [az deployment group create][az-deployment-group-create] to create the resource.
174191

175192
```azurecli
@@ -179,34 +196,52 @@ az deployment group create \
179196
--parameters azuredeploy.parameters.json \
180197
--parameters userAssignedIdentity=$sourceResourceID
181198
```
182-
199+
200+
Take note of the resource ID (`id`) of the pipeline, which is used in later steps. Example:
201+
202+
```
203+
"/subscriptions/<subscriptionID>/resourceGroups/<resourceGroupName>/providers/Microsoft.ContainerRegistry/registries/<sourceRegistryName>/exportPipelines/myExportPipeline"
204+
```
205+
183206
### Run the ExportPipeline resource
184207

208+
Create a PipelineRun resource for your source container registry using Azure Resource Manager template deployment. This resource runs the ExportPipeline resource you created in the previous step, and exports specified images from your container registry to your source storage account. As shown in a later step, you can also use a PipelineRun resource to trigger an ImportPipeline for image import to your target container registry.
209+
185210
Copy ExportPipeline Resource Manager template files from [here](add link - TBD).
186211

187-
[Create a list of images to transfer - what is format?]
212+
Enter the following parameter values in the file `azuredeploy.parameters.json`:
213+
214+
|Parameter |Value |
215+
|---------|---------|
216+
|registryName | Name of your source container registry |
217+
|pipelineRunName | Name you choose for the run |
218+
|pipelineResourceId | Resource ID of the export pipeline. Example: `/subscriptions/<subscriptionID>/resourceGroups/<resourceGroupName>/providers/Microsoft.ContainerRegistry/registries/<sourceRegistryName>/exportPipelines/myExportPipeline` |
219+
|targetName | Name you choose for the blob for exported artifacts in your source storage account, such a *myblob*
220+
|artifacts | Array of source images to transfer. Example: `[samples/hello-world:v1", "samples/nginx:v1"]`
188221

189222
Run [az deployment group create][az-deployment-group-create] to run the resource.
190223

191224
```azurecli
192-
az group deployment create \
225+
az deployment group create \
193226
--resource-group myResourceGroup \
194227
--template-file azuredeploy.json \
195228
--parameters azuredeploy.parameters.json
196229
```
197230

231+
For image export, when prompted, leave the `sourceName` blank. You can also leave `catalogDigest` and `forceUpdateTag` values blank.
232+
233+
When deployment completes successfully, verify image export by viewing the exported blob in the *transfer* container of the source storage account.
234+
198235
## Transfer blob (optional)
199236

200237
Use the AzCopy command to copy the blob from the source storage account to the target storage account. See [Copy blobs between storage accounts](/storage/common/storage-use-azcopy-blobs.md#copy-blobs-between-storage-accounts).
201238

202-
[TODO: What does the AzCopy command look like? Is it the `azcopy sync` shown below?]
203-
204-
The following `azcopy sync` command ynchronizes the transfer containers in the source and target storage accounts:
239+
For example, the following [`azcopy sync`](/azure/storage/common/storage-ref-azcopy-sync) command synchronizes the *transfer* container from the source storage account with the *transfer* container in the target account. Authentication uses the export and import SAS tokens previously saved in environment variables:
205240

206241
```console
207242
azcopy sync \
208-
'https://<source-storage-account-name>.blob.core.windows.net/transfer' \
209-
'https://<destination-storage-account-name>.blob.core.windows.net/transfer' \
243+
'https://<source-storage-account-name>.blob.core.windows.net/transfer/'$EXPORT_SAS \
244+
'https://<destination-storage-account-name>.blob.core.windows.net/transfer/'$IMPORT_SAS \
210245
--recursive
211246
```
212247

@@ -218,6 +253,15 @@ Create an ImportPipeline resource in your target container registry using Azure
218253

219254
Copy ImportPipeline Resource Manager template files from [here](add link - TBD).
220255

256+
Enter the following parameter values in the file `azuredeploy.parameters.json`:
257+
258+
Parameter |Value |
259+
|---------|---------|
260+
|registryName | Name of your target container registry |
261+
|importPipelineName | Name you choose for the import pipeline |
262+
|sourceUri | URI of the container in your target storage account, used as a source for the import pipeline. Example: `https://targetstorage.blob.core.windows.net/transfer` |
263+
|keyVaultUri | URI of the SAS token secret in the target key vault. Example: `https://targetvault.vault-int.azure-int.net/secrets/acrimportsas` |
264+
221265
Run [az deployment group create][az-deployment-group-create] to create the resource.
222266

223267
```azurecli
@@ -228,22 +272,40 @@ az group deployment create \
228272
--parameters userAssignedIdentity=$targetResourceID
229273
```
230274

275+
When deployment completes successfully, verify image import by listing the repositories in the target container registry.
276+
231277
### Run the ImportPipeline resource manually (optional)
232278

233-
Copy ImportPipeline Resource Manager template files from [here](add link - TBD).
279+
You can also use a PipelineRun resource to trigger an ImportPipeline for image import to your target container registry.
280+
281+
Copy ExportPipeline Resource Manager template files from [here](add link - TBD).
282+
283+
Enter the following parameter values in the file `azuredeploy.parameters.json`:
284+
285+
|Parameter |Value |
286+
|---------|---------|
287+
|registryName | Name of your source container registry |
288+
|pipelineRunName | Name you choose for the run |
289+
|pipelineResourceId | Resource ID of the import pipeline. Example: `/subscriptions/<subscriptionID>/resourceGroups/<resourceGroupName>/providers/Microsoft.ContainerRegistry/registries/<sourceRegistryName>/exportPipelines/myExportPipeline` |
290+
|sourceName | Name of the blob for exported artifacts in your storage account, such a *myblob*
234291

235292
Run [az deployment group create][az-deployment-group-create] to run the resource.
236-
293+
237294
```azurecli
238-
az group deployment create \
239-
--resource-group myResourceGroup \
240-
--template-file azuredeploy.json \
241-
--parameters azuredeploy.parameters.json
295+
az deployment group create \
296+
--resource-group myResourceGroup \
297+
--template-file azuredeploy.json \
298+
--parameters azuredeploy.parameters.json
242299
```
243300

244-
## Verify image transfer
301+
For image export, when prompted, leave the `targetName` blank. You can also leave `catalogDigest` and `forceUpdateTag` values blank.
302+
303+
When deployment completes successfully, verify image import by listing the repositories in the target container registry.
304+
305+
## Manage pipeline resources
306+
307+
[TODO: How to delete, etc.]
245308

246-
[TODO]
247309

248310
<!-- LINKS - External -->
249311

0 commit comments

Comments
 (0)