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
+52-66Lines changed: 52 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,20 @@
1
1
---
2
2
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
4
4
ms.topic: article
5
-
ms.date: 03/25/2020
5
+
ms.date: 04/13/2020
6
6
---
7
7
8
8
# Run ACR Tasks using Resource Manager templates
9
9
10
10
[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.
11
11
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.
13
13
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:
15
15
16
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. 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
18
18
19
19
## Limitations
20
20
@@ -24,35 +24,40 @@ A Resource Manager template to queue a task is useful in automation scenarios. F
24
24
## Prerequisites
25
25
26
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.
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.
28
28
29
29
## Example: Create registry and queue a build task
30
30
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.
36
32
37
33
### Deploy the template
38
34
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.
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*.
138
109
139
-
## Example: Task with managed identity
110
+
The portal shows the task log.
140
111
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
142
113
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.
144
117
145
118
### Prepare a base registry
146
119
@@ -158,7 +131,7 @@ For demonstration purposes, create a separate container registry as your base re
158
131
159
132
### Create a new Dockerfile
160
133
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`.
162
135
163
136
1. In the GitHub UI, select **Create new file**.
164
137
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 \
196
169
197
170
### Deploy the template
198
171
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.
Copy file name to clipboardExpand all lines: includes/container-registry-tasks-user-assigned-id.md
+16-5Lines changed: 16 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,21 +14,32 @@ ms.custom: include file
14
14
15
15
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.
16
16
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
19
21
```
20
22
21
23
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.
22
24
23
25
```azurecli
24
26
# 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)
26
31
27
32
# Get principal ID of the task's user-assigned identity
0 commit comments