You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/container-registry/container-registry-tasks-template.md
+41-28Lines changed: 41 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,10 +11,10 @@ ms.date: 04/13/2020
11
11
12
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.
13
13
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:
14
+
A Resource Manager template to queue a task is useful in automation scenarios and extends the functionality of`az acr build`. For example:
15
15
16
-
* 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
16
+
* Use a template to create a container registry and immediately queue an ACR task to build and push a container image
17
+
*Create or enable additional resources you can use in a quick task, such as a managed identity for Azure resources
18
18
19
19
## Limitations
20
20
@@ -23,24 +23,27 @@ A Resource Manager template to queue a task is useful in automation scenarios an
23
23
24
24
## Prerequisites
25
25
26
-
***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.
26
+
***GitHub account** - Create an account on https://github.com if you don't already have one.
27
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.
28
28
29
-
## Example: Create registry and queue a build task
29
+
## Example: Create registry and queue build task
30
30
31
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.
32
32
33
-
### Deploy the template
33
+
### Template parameters
34
34
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*.
35
+
For this example, provide values for the following template parameters:
36
36
37
-
To use the template, provide the following parameters:
37
+
|Parameter |Value |
38
+
|---------|---------|
39
+
|registryName |Unique name of registry that's created |
40
+
|repository |Target repository for build task |
41
+
|taskRunName |Name of task run, which specifies image tag |
42
+
|sourceLocation |Remote context for the build task, for example, *https://github.com/Azure-Samples/acr-build-helloworld-node*. The Dockerfile in the repo root builds a container image for a small Node.js web app. If desired, use your fork of the repo as the build context. |
38
43
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.
44
+
### Deploy the template
45
+
46
+
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*.
The previous command passes the parameters on the command line. If desired, pass them in the file azuredeploy.parameters.json.
59
+
The previous command passes the parameters on the command line. If desired, pass them in a [parameters file](../azure-resource-manager/templates/parameter-files.md).
57
60
58
61
### Verify deployment
59
62
@@ -77,7 +80,7 @@ testtask
77
80
78
81
To view details about the task run, view the run log.
79
82
80
-
First get the run ID with [az acr task list-runs][az-acr-task-list-runs]
83
+
First, get the run ID with [az acr task list-runs][az-acr-task-list-runs]
81
84
```azurecli
82
85
az acr task list-runs \
83
86
--registry mycontainerregistry --output table
@@ -111,11 +114,9 @@ The portal shows the task log.
111
114
112
115
## Example: Queue task with managed identity
113
116
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.
117
+
Use a [sample 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 [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 centralized registry with base images accessed by multiple development teams.
115
118
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.
117
-
118
-
### Prepare a base registry
119
+
### Prepare base registry
119
120
120
121
For demonstration purposes, create a separate container registry as your base registry, and push a Node.js base image pulled from Docker Hub.
121
122
@@ -129,9 +130,9 @@ For demonstration purposes, create a separate container registry as your base re
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`.
135
+
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*.
135
136
136
137
1. In the GitHub UI, select **Create new file**.
137
138
1. Name your file *Dockerfile-test* and paste the following contents. Substitute your registry name for *mybaseregistry*.
@@ -150,7 +151,7 @@ Create a Dockerfile that pulls the base image from your base registry. Perform t
150
151
151
152
Give the managed identity permissions to pull from the base registry, *mybaseregistry*.
152
153
153
-
First use the [az acr show][az-acr-show] command to get the resource ID of the base registry and store it in a variable:
154
+
Use the [az acr show][az-acr-show] command to get the resource ID of the base registry and store it in a variable:
154
155
155
156
```azurecli
156
157
baseregID=$(az acr show \
@@ -167,12 +168,24 @@ az role assignment create \
167
168
--role acrpull
168
169
```
169
170
170
-
### Deploy the template
171
+
### Template parameters
172
+
173
+
For this example, provide values for the following template parameters:
171
174
172
-
To use the template, provide the following parameters:
175
+
|Parameter |Value |
176
+
|---------|---------|
177
+
|registryName |Name of registry where image is built |
178
+
|repository |Target repository for build task |
179
+
|taskRunName |Name of task run, which specifies image tag |
180
+
|userAssignedIdentity |Resource ID of user-assigned identity enabled in the task|
181
+
|customRegistryIdentity | Client ID of user-assigned identity enabled in the task, used to authenticate with custom registry |
182
+
|customRegistry |Log in server name of the custom registry accessed in the task, for example, *mybaseregistry.azurecr.io*|
183
+
|sourceLocation |Remote context for the build task, for example, *https://github.com/\<your-GitHub-ID\>/acr-build-helloworld-node.*|
184
+
|dockerFilePath | Path to the Dockerfile at the remote context, used to build the image. |
185
+
186
+
### Deploy the template
173
187
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.
188
+
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*. The base image is pulled from *mybaseregistry.azurecr.io*.
176
189
177
190
```azurecli
178
191
az deployment group create \
@@ -189,7 +202,7 @@ az deployment group create \
189
202
customRegistry=mybaseregistry.azurecr.io
190
203
```
191
204
192
-
The previous command passes the parameters on the command line. If desired, pass them in the file azuredeploy.parameters.json.
205
+
The previous command passes the parameters on the command line. If desired, pass them in a [parameters file](../azure-resource-manager/templates/parameter-files.md).
0 commit comments