Skip to content

Commit 9534132

Browse files
committed
updates in progress
1 parent 8685c65 commit 9534132

File tree

2 files changed

+68
-71
lines changed

2 files changed

+68
-71
lines changed

articles/container-registry/container-registry-tasks-template.md

Lines changed: 52 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
---
22
title: Run task using template
3-
description: Run an ACR task using an Azure Resource Manager template
3+
description: Run an ACR quick task using an Azure Resource Manager template
44
ms.topic: article
5-
ms.date: 03/25/2020
5+
ms.date: 04/13/2020
66
---
77

88
# Run ACR Tasks using Resource Manager templates
99

1010
[ACR Tasks](container-registry-tasks-overview.md) is a suite of features within Azure Container Registry to help you manage and modify container images across the container lifecycle.
1111

12-
This article shows how to use an Azure Resource Manager template to queue a [quick task](container-registry-tasks-overview.md#quick-task), similar to one you can create manually using the [az acr build][az-acr-build] command.
12+
This article shows Azure Resource Manager template examples to queue a [quick task](container-registry-tasks-overview.md#quick-task), similar to one you can create manually using the [az acr build][az-acr-build] command.
1313

14-
A Resource Manager template to queue a task is useful in automation scenarios. For example:
14+
A Resource Manager template to queue a task is useful in automation scenarios and extends the functionality in a quick task with `az acr build`. For example:
1515

1616
* Use a template to create a container registry and immediately queue an ACR task to build or push a container image
17-
* Automate creation of additional resources you can use in a quick task, such as a managed identity for Azure resources. The template-based creation of a quick task allows you to use a managed identity, which currently isn't supported with `az acr build`.
17+
* Automate creation of additional resources you can use in a quick task, such as a managed identity for Azure resources
1818

1919
## Limitations
2020

@@ -24,35 +24,40 @@ A Resource Manager template to queue a task is useful in automation scenarios. F
2424
## Prerequisites
2525

2626
* **GitHub account** - Create an account on https://github.com if you don't already have one. This tutorial series uses a GitHub repository to demonstrate automated image builds in ACR Tasks.
27-
* **Fork sample repository** - Use the GitHub UI to fork the following sample repository into your GitHub account: https://github.com/Azure-Samples/acr-build-helloworld-node. This repo contains sample Dockerfiles and source code to build small container images.
27+
* **Fork sample repository** - For the task examples shown here, use the GitHub UI to fork the following sample repository into your GitHub account: https://github.com/Azure-Samples/acr-build-helloworld-node. This repo contains sample Dockerfiles and source code to build small container images.
2828

2929
## Example: Create registry and queue a build task
3030

31-
This example uses a [sample template](https://github.com/Azure/acr/tree/master/docs/tasks/run-as-deployment/quickdockerbuild) that creates a container registry and queues a task to build and push an image. To use the template:
32-
33-
* First create a resource group, or use an existing group
34-
* Specify a unique registry name
35-
* Point to a remote GitHub repo for the build context, such as https://github.com/<your-GitHub-ID>/acr-build-helloworld-node. The Dockerfile in the root of this repo builds a container image for small Node.js web app.
31+
This example uses a [sample template](https://github.com/Azure/acr/tree/master/docs/tasks/run-as-deployment/quickdockerbuild) to create a container registry and queue a task that builds and pushes an image.
3632

3733
### Deploy the template
3834

39-
Deploy the template with the [az deployment group create][az-deployment-group-create] command. This example builds and pushes the *helloworld-node:testtask* image to a registry named *mycontainerregistry*:
35+
Deploy the template with the [az deployment group create][az-deployment-group-create] command. This example builds and pushes the *helloworld-node:testtask* image to a registry named *mycontainerregistry*.
36+
37+
To use the template, provide the following parameters:
38+
39+
* The name of a resource group
40+
* A unique name for the container registry that's created
41+
* The repository target of the task
42+
* The name of the task, which specifies the image tag
43+
* The remote GitHub repo for the build context, for example, https://github.com/Azure-Samples/acr-build-helloworld-node. The Dockerfile in the root of this repo builds a container image for small Node.js web app. If desired, use your fork of the repo as the build context.
4044

4145
```azurecli
4246
az deployment group create \
4347
--resource-group myResourceGroup \
4448
--template-uri https://raw.githubusercontent.com/Azure/acr/master/docs/tasks/run-as-deployment/quickdockerbuild/azuredeploy.json \
45-
--parameters azuredeploy.parameters.json \
4649
--parameters \
4750
registryName=mycontainerregistry \
48-
taskRunName=testtask \
4951
repository=helloworld-node \
50-
sourceLocation=https://github.com/<your-GitHub-ID>/acr-build-helloworld-node.git
52+
taskRunName=testtask \
53+
sourceLocation=https://github.com/Azure-Samples/acr-build-helloworld-node.git
5154
```
5255

56+
The previous command passes the parameters on the command line. If desired, pass them in the file azuredeploy.parameters.json.
57+
5358
### Verify deployment
5459

55-
Verify the image is built by running [az acr repository show-tags][az-acr-repository-show-tags]:
60+
After the deployment completes successfully, verify the image is built by running [az acr repository show-tags][az-acr-repository-show-tags]:
5661

5762
```azurecli
5863
az acr repository show-tags \
@@ -94,53 +99,21 @@ az acr task logs \
9499
--run-id ca1
95100
```
96101

97-
Output is similar to:
102+
The output shows the task log.
98103

99-
```console
100-
2020/03/23 17:54:29 Downloading source code...
101-
2020/03/23 17:54:49 Finished downloading source code
102-
2020/03/23 17:54:50 Using acb_vol_076f6d6d-209f-4b12-8a2a-936e3279ef6f as the home volume
103-
2020/03/23 17:54:50 Setting up Docker configuration...
104-
2020/03/23 17:54:51 Successfully set up Docker configuration
105-
2020/03/23 17:54:51 Logging in to registry: mycontainerregistry.azurecr.io
106-
2020/03/23 17:54:52 Successfully logged into mycontainerregistry.azurecr.io
107-
2020/03/23 17:54:52 Executing step ID: build. Timeout(sec): 28800, Working directory: '', Network: ''
108-
2020/03/23 17:54:52 Scanning for dependencies...
109-
2020/03/23 17:54:53 Successfully scanned dependencies
110-
2020/03/23 17:54:53 Launching container with name: build
111-
Sending build context to Docker daemon 89.09kB
112-
Step 1/5 : FROM node:9-alpine
113-
[...]
114-
testtask: digest: sha256:770789bd67d6ae1cc3eef9035b796ffc1616b1f9d117cf5c83cf48aec89ac464 size: 1367
115-
2020/03/23 17:55:13 Successfully pushed image: mycontainerregistry.azurecr.io/helloworld-node:testtask
116-
2020/03/23 17:55:13 Step ID: build marked as successful (elapsed time in seconds: 11.468590)
117-
2020/03/23 17:55:13 Populating digests for step ID: build...
118-
2020/03/23 17:55:15 Successfully populated digests for step ID: build
119-
2020/03/23 17:55:15 Step ID: push marked as successful (elapsed time in seconds: 9.269134)
120-
2020/03/23 17:55:15 The following dependencies were found:
121-
2020/03/23 17:55:15
122-
- image:
123-
registry: mycontainerregistry.azurecr.io
124-
repository: helloworld-node
125-
tag: testtask
126-
digest: sha256:770789bd67d6ae1cc3eef9035b796ffc1616b1f9d117cf5c83cf48aec89ac464
127-
runtime-dependency:
128-
registry: registry.hub.docker.com
129-
repository: library/node
130-
tag: 9-alpine
131-
digest: sha256:8dafc0968fb4d62834d9b826d85a8feecc69bd72cd51723c62c7db67c6dec6fa
132-
git:
133-
git-head-revision: a3710d1af24d20fbdc6bb3feeea428fa01138e93
134-
135-
136-
Run ID: ca1 was successful after 47s
137-
```
104+
You can also view the task run log in the Azure portal.
105+
106+
1. Navigate to your container registry
107+
2. Under **Services**, select **Tasks** > **Runs**.
108+
3. Select the run ID, in this case *ca1*.
138109

139-
## Example: Task with managed identity
110+
The portal shows the task log.
140111

141-
This [deployment example](https://github.com/Azure/acr/tree/master/docs/tasks/run-as-deployment/quickdockerbuildwithidentity) queues a task that uses a user-assigned managed identity. During the task run, the identity authenticates to pull an image from another Azure container registry. This scenario is similar to the one in [Cross-registry authentication in an ACR task using an Azure-managed identity](container-registry-tasks-cross-registry-authentication.md). For example, an organization might maintain a *base registry* with base images accessed by multiple development teams.
112+
## Example: Queue task with managed identity
142113

143-
For this example, you create a managed identity before queuing the task. However, you can also set up a template to automate creation of the identity.
114+
Use an [example template](https://github.com/Azure/acr/tree/master/docs/tasks/run-as-deployment/quickdockerbuildwithidentity) to queue a task that enables a user-assigned managed identity. During the task run, the identity authenticates to pull an image from another Azure container registry. This scenario is similar to the one in [Cross-registry authentication in an ACR task using an Azure-managed identity](container-registry-tasks-cross-registry-authentication.md). For example, an organization might maintain a *base registry* with base images accessed by multiple development teams.
115+
116+
The following steps provide commands to create a managed identity before queuing the task. However, you can also set up the task template to automate creation of the identity.
144117

145118
### Prepare a base registry
146119

@@ -158,7 +131,7 @@ For demonstration purposes, create a separate container registry as your base re
158131

159132
### Create a new Dockerfile
160133

161-
Create a Dockerfile that pulls the base image from your base registry.
134+
Create a Dockerfile that pulls the base image from your base registry. Perform the following steps in your local fork of the GitHub repo, for example, `https://github.com/<your-GitHub-ID>/acr-build-helloworld-node.git`.
162135

163136
1. In the GitHub UI, select **Create new file**.
164137
1. Name your file *Dockerfile-test* and paste the following contents. Substitute your registry name for *mybaseregistry*.
@@ -196,23 +169,31 @@ az role assignment create \
196169

197170
### Deploy the template
198171

172+
To use the template, provide the following parameters:
173+
174+
* The name of a resource group
175+
* The remote GitHub repo for the build context, for example, https://github.com/Azure-Samples/acr-build-helloworld-node. The Dockerfile in the root of this repo builds a container image for small Node.js web app. If desired, use your fork of the repo as the build context.
176+
199177
```azurecli
200178
az deployment group create \
201179
--resource-group myResourceGroup \
202180
--template-uri https://raw.githubusercontent.com/Azure/acr/master/docs/tasks/run-as-deployment/quickdockerbuildwithidentity/azuredeploy.json \
203-
--parameters azuredeploy.parameters.json \
204181
--parameters \
205182
registryName=mycontainerregistry \
206-
taskRunName=basetask \
207183
repository=helloworld-node \
184+
taskRunName=basetask \
208185
userAssignedIdentity=$resourceID \
209-
identityCredential=$clientID \
186+
customRegistryIdentity=$clientID \
210187
sourceLocation=https://github.com/<your-GitHub-ID>/acr-build-helloworld-node.git \
211188
dockerFilePath=Dockerfile-test \
212-
baseRegistry=mybaseregistry.azurecr.io
189+
customRegistry=mybaseregistry.azurecr.io
213190
```
214191

215-
Verify the image is built by running [az acr repository show-tags][az-acr-repository-show-tags]:
192+
The previous command passes the parameters on the command line. If desired, pass them in the file azuredeploy.parameters.json.
193+
194+
### Verify deployment
195+
196+
After the deployment completes successfully, verify the image is built by running [az acr repository show-tags][az-acr-repository-show-tags]:
216197

217198
```azurecli
218199
az acr repository show-tags \
@@ -228,6 +209,8 @@ Result
228209
basetask
229210
```
230211

212+
### View run log
213+
231214
To view the run log, see steps in the [preceding section](#view-run-log).
232215

233216
## Next steps
@@ -239,9 +222,12 @@ To view the run log, see steps in the [preceding section](#view-run-log).
239222
<!-- LINKS - Internal -->
240223
[azure-cli]: /cli/azure/install-azure-cli
241224
[az-acr-build]: /cli/azure/acr#az-acr-build
225+
[az-acr-show]: /cli/azure/acr#az-acr-show
242226
[az-acr-task-run]: /cli/azure/acr/task#az-acr-task-run
243227
[az-acr-task-logs]: /cli/azure/acr/task#az-acr-task-logs
228+
[az-acr-repository-show-tags]: /cli/azure/acr/repository#az-acr-repository-show-tags
244229
[az-acr-task-list-runs]: /cli/azure/acr/task#az-acr-task-list-runs
245230
[az-deployment-group-create]: /cli/azure/deployment/group#az-deployment-group-create
246231
[az-identity-create]: /cli/azure/identity#az-identity-create
247-
[az-identity-show]: /cli/azure/identity#az-identity-show
232+
[az-identity-show]: /cli/azure/identity#az-identity-show
233+
[az-role-assignment-create]: /cli/azure/role/assignment#az-role-assignment-create

includes/container-registry-tasks-user-assigned-id.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,32 @@ ms.custom: include file
1414

1515
Create an identity named *myACRTasksId* in your subscription using the [az identity create][az-identity-create] command. You can use the same resource group you used previously to create a container registry, or a different one.
1616

17-
```azurecli-interactive
18-
az identity create --resource-group myResourceGroup --name myACRTasksId
17+
```azurecli
18+
az identity create \
19+
--resource-group myResourceGroup \
20+
--name myACRTasksId
1921
```
2022

2123
To configure the user-assigned identity in the following steps, use the [az identity show][az-identity-show] command to store the identity's resource ID, principal ID, and client ID in variables.
2224

2325
```azurecli
2426
# Get resource ID of the user-assigned identity
25-
resourceID=$(az identity show --resource-group myResourceGroup --name myACRTasksId --query id --output tsv)
27+
resourceID=$(az identity show \
28+
--resource-group myResourceGroup \
29+
--name myACRTasksId \
30+
--query id --output tsv)
2631
2732
# Get principal ID of the task's user-assigned identity
28-
principalID=$(az identity show --resource-group myResourceGroup --name myACRTasksId --query principalId --output tsv)
33+
principalID=$(az identity show \
34+
--resource-group myResourceGroup \
35+
--name myACRTasksId \
36+
--query principalId --output tsv)
2937
3038
# Get client ID of the user-assigned identity
31-
clientID=$(az identity show --resource-group myResourceGroup --name myACRTasksId --query clientId --output tsv)
39+
clientID=$(az identity show \
40+
--resource-group myResourceGroup \
41+
--name myACRTasksId \
42+
--query clientId --output tsv)
3243
```
3344

3445
<!-- LINKS - Internal -->

0 commit comments

Comments
 (0)