Skip to content

Commit 307e2c0

Browse files
committed
draft complete
1 parent ce9876e commit 307e2c0

File tree

1 file changed

+41
-28
lines changed

1 file changed

+41
-28
lines changed

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

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ ms.date: 04/13/2020
1111

1212
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 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:
1515

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
1818

1919
## Limitations
2020

@@ -23,24 +23,27 @@ A Resource Manager template to queue a task is useful in automation scenarios an
2323

2424
## Prerequisites
2525

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.
2727
* **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

29-
## Example: Create registry and queue a build task
29+
## Example: Create registry and queue build task
3030

3131
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.
3232

33-
### Deploy the template
33+
### Template parameters
3434

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:
3636

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. |
3843

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*.
4447

4548
```azurecli
4649
az deployment group create \
@@ -50,10 +53,10 @@ az deployment group create \
5053
registryName=mycontainerregistry \
5154
repository=helloworld-node \
5255
taskRunName=testtask \
53-
sourceLocation=https://github.com/Azure-Samples/acr-build-helloworld-node.git
56+
sourceLocation=https://github.com/Azure-Samples/acr-build-helloworld-node.git
5457
```
5558

56-
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).
5760

5861
### Verify deployment
5962

@@ -77,7 +80,7 @@ testtask
7780

7881
To view details about the task run, view the run log.
7982

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]
8184
```azurecli
8285
az acr task list-runs \
8386
--registry mycontainerregistry --output table
@@ -111,11 +114,9 @@ The portal shows the task log.
111114

112115
## Example: Queue task with managed identity
113116

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.
115118

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
119120

120121
For demonstration purposes, create a separate container registry as your base registry, and push a Node.js base image pulled from Docker Hub.
121122

@@ -129,9 +130,9 @@ For demonstration purposes, create a separate container registry as your base re
129130
docker push mybaseregistry.azurecr.io/baseimages/node:9-alpine
130131
```
131132

132-
### Create a new Dockerfile
133+
### Create new Dockerfile
133134

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`.
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*.
135136

136137
1. In the GitHub UI, select **Create new file**.
137138
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
150151

151152
Give the managed identity permissions to pull from the base registry, *mybaseregistry*.
152153

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:
154155

155156
```azurecli
156157
baseregID=$(az acr show \
@@ -167,12 +168,24 @@ az role assignment create \
167168
--role acrpull
168169
```
169170

170-
### Deploy the template
171+
### Template parameters
172+
173+
For this example, provide values for the following template parameters:
171174

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
173187

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*.
176189

177190
```azurecli
178191
az deployment group create \
@@ -189,7 +202,7 @@ az deployment group create \
189202
customRegistry=mybaseregistry.azurecr.io
190203
```
191204

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).
193206

194207
### Verify deployment
195208

0 commit comments

Comments
 (0)