Skip to content

Commit ba830a0

Browse files
authored
Merge pull request #311226 from v-albemi/event-driven
Freshness Edit: Azure Container Apps
2 parents 0738d07 + 0946586 commit ba830a0

1 file changed

Lines changed: 45 additions & 45 deletions

File tree

articles/container-apps/tutorial-event-driven-jobs.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
---
2-
title: 'Tutorial: Deploy an event-driven job with Azure Container Apps'
3-
description: Learn to create a job that processes queue messages with Azure Container Apps
2+
title: 'Tutorial: Deploy an Event-Driven Job with Azure Container Apps'
3+
description: Learn how to create a job that processes queue messages by using Azure Container Apps.
44
services: container-apps
55
author: craigshoemaker
66
ms.service: azure-container-apps
77
ms.topic: conceptual
8-
ms.date: 12/09/2024
8+
ms.date: 02/02/2026
99
ms.author: cshoe
1010
ms.custom:
1111
- build-2023
1212
- devx-track-azurecli
1313
- sfi-ropc-nochange
1414
---
1515

16-
# Tutorial: Deploy an event-driven job with Azure Container Apps
16+
# Tutorial: Deploy an event-driven job by using Azure Container Apps
1717

18-
Azure Container Apps [jobs](jobs.md) allow you to run containerized tasks that execute for a finite duration and exit. You can trigger a job execution manually, on a schedule, or based on events. Jobs are best suited to for tasks such as data processing, machine learning, resource cleanup, or any scenario that requires serverless ephemeral compute resources.
18+
Azure Container Apps [jobs](jobs.md) enable you to run containerized tasks that run for a finite duration and then stop. You can trigger a job execution manually, on a schedule, or based on events. Jobs are best suited to for tasks such as data processing, machine learning, resource cleanup, or any scenario that requires serverless ephemeral compute resources.
1919

2020
In this tutorial, you learn how to work with [event-driven jobs](jobs.md#event-driven-jobs).
2121

2222
> [!div class="checklist"]
23-
> * Create a Container Apps environment to deploy your container apps
24-
> * Create an Azure Storage Queue to send messages to the container app
23+
> * Create a Container Apps environment in which to deploy your container apps
24+
> * Create an Azure Storage queue to send messages to the container app
2525
> * Build a container image that runs a job
2626
> * Deploy the job to the Container Apps environment
2727
> * Verify that the queue messages are processed by the container app
2828
29-
The job you create starts an execution for each message that is sent to an Azure Storage queue. Each job execution runs a container that performs the following steps:
29+
The job you create starts an execution for each message that's sent to an Azure Storage queue. Each job execution runs a container that performs the following steps:
3030

3131
1. Gets one message from the queue.
3232
1. Logs the message to the job execution logs.
3333
1. Deletes the message from the queue.
34-
1. Exits.
34+
1. Stops.
3535

3636
> [!IMPORTANT]
37-
> The scaler monitors the queue's length to determine how many jobs to start. For accurate scaling, don't delete a message from the queue until the job execution has finished processing it.
37+
> The scaler monitors the queue's length to determine how many jobs to start. For accurate scaling, don't delete a message from the queue until the job execution finishes processing it.
3838
3939
The source code for the job you run in this tutorial is available in an Azure Samples [GitHub repository](https://github.com/Azure-Samples/container-apps-event-driven-jobs-tutorial/blob/main/index.js).
4040

@@ -46,12 +46,12 @@ The job uses an Azure Storage queue to receive messages. In this section, you cr
4646

4747
1. Define a name for your storage account.
4848

49-
```bash
49+
```azurecli
5050
STORAGE_ACCOUNT_NAME="<STORAGE_ACCOUNT_NAME>"
5151
QUEUE_NAME="myqueue"
5252
```
5353
54-
Replace `<STORAGE_ACCOUNT_NAME>` with a unique name for your storage account. Storage account names must be *unique within Azure* and be from 3 to 24 characters in length containing numbers and lowercase letters only.
54+
Replace `<STORAGE_ACCOUNT_NAME>` with a unique name for your storage account. Storage account names must be unique within Azure. They must be between 3 and 24 characters long and contain numbers and lowercase letters only.
5555
5656
1. Create an Azure Storage account.
5757
@@ -64,27 +64,27 @@ The job uses an Azure Storage queue to receive messages. In this section, you cr
6464
--kind StorageV2
6565
```
6666
67-
If this command returns the error:
67+
If this command returns the following error, be sure you have registered the `Microsoft.Storage` namespace in your Azure subscription.
6868
6969
```
7070
(SubscriptionNotFound) Subscription <SUBSCRIPTION_ID> was not found.
7171
Code: SubscriptionNotFound
7272
Message: Subscription <SUBSCRIPTION_ID> was not found.
7373
```
7474
75-
Be sure you have registered the `Microsoft.Storage` namespace in your Azure subscription.
75+
Use this command to register the namespace:
7676
7777
```azurecli
7878
az provider register --namespace Microsoft.Storage
7979
```
8080
81-
1. Save the queue's connection string into a variable.
81+
1. Save the queue's connection string into a variable:
8282
83-
```bash
83+
```azurecli
8484
QUEUE_CONNECTION_STRING=$(az storage account show-connection-string -g $RESOURCE_GROUP --name $STORAGE_ACCOUNT_NAME --query connectionString --output tsv)
8585
```
8686
87-
1. Create the message queue.
87+
1. Create the message queue:
8888
8989
```azurecli
9090
az storage queue create \
@@ -95,11 +95,11 @@ The job uses an Azure Storage queue to receive messages. In this section, you cr
9595
9696
## Create a user-assigned managed identity
9797
98-
To avoid using administrative credentials, pull images from private repositories in Microsoft Azure Container Registry using managed identities for authentication. When possible, use a user-assigned managed identity to pull images.
98+
To avoid using administrative credentials, pull images from private repositories in Azure Container Registry. Use managed identities for authentication. When possible, use a user-assigned managed identity to pull images.
9999
100-
1. Create a user-assigned managed identity. Before you run the following commands, choose a name for your managed identity and replace the `\<PLACEHOLDER\>` with the name.
100+
1. Create a user-assigned managed identity. Before you run the following commands, choose a name for your managed identity and create the following variable:
101101
102-
```bash
102+
```azurecli
103103
IDENTITY="<YOUR_IDENTITY_NAME>"
104104
```
105105
@@ -109,7 +109,7 @@ To avoid using administrative credentials, pull images from private repositories
109109
--resource-group $RESOURCE_GROUP
110110
```
111111
112-
1. Get the identity's resource ID.
112+
1. Get the identity's resource ID:
113113
114114
```azurecli
115115
IDENTITY_ID=$(az identity show \
@@ -121,18 +121,18 @@ To avoid using administrative credentials, pull images from private repositories
121121
122122
## Build and deploy the job
123123
124-
To deploy the job, you must first build a container image for the job and push it to a registry. Then, you can deploy the job to the Container Apps environment.
124+
To deploy the job, you must first build a container image for it and push the container to a registry. You can then deploy the job to the Container Apps environment.
125125
126-
1. Define a name for your container image and registry.
126+
1. Define a name for your container image and registry:
127127
128128
```bash
129129
CONTAINER_IMAGE_NAME="queue-reader-job:1.0"
130130
CONTAINER_REGISTRY_NAME="<CONTAINER_REGISTRY_NAME>"
131131
```
132132
133-
Replace `<CONTAINER_REGISTRY_NAME>` with a unique name for your container registry. Container registry names must be *unique within Azure* and be from 5 to 50 characters in length containing numbers and lowercase letters only.
133+
Replace `<CONTAINER_REGISTRY_NAME>` with a unique name for your container registry. Container registry names must be unique within Azure. They must be between 5 and 50 characters long and contain numbers and lowercase letters only.
134134
135-
1. Create a container registry.
135+
1. Create a container registry:
136136
137137
```azurecli
138138
az acr create \
@@ -144,27 +144,27 @@ To deploy the job, you must first build a container image for the job and push i
144144
145145
1. Your container registry must allow Azure Resource Manager (ARM) audience tokens for authentication in order to use managed identity to pull images.
146146
147-
Use the following command to check if ARM tokens are allowed to access your Azure Container Registry (ACR).
147+
Use the following command to check whether ARM tokens are allowed to access your Azure container registry:
148148
149149
```azurecli
150150
az acr config authentication-as-arm show --registry "$CONTAINER_REGISTRY_NAME"
151151
```
152152
153-
If ARM tokens are allowed, the command outputs the following.
153+
If ARM tokens are allowed, you see the following output:
154154
155155
```
156156
{
157157
"status": "enabled"
158158
}
159159
```
160160
161-
If the `status` is `disabled`, allow ARM tokens with the following command.
161+
If the `status` is `disabled`, allow ARM tokens by using the following command:
162162
163163
```azurecli
164164
az acr config authentication-as-arm update --registry "$CONTAINER_REGISTRY_NAME" --status enabled
165165
```
166166
167-
1. The source code for the job is available on [GitHub](https://github.com/Azure-Samples/container-apps-event-driven-jobs-tutorial). Run the following command to clone the repository and build the container image in the cloud using the `az acr build` command.
167+
1. The source code for the job is available on [GitHub](https://github.com/Azure-Samples/container-apps-event-driven-jobs-tutorial). Run the following command to clone the repository and build the container image in the cloud:
168168
169169
```azurecli
170170
az acr build \
@@ -175,7 +175,7 @@ To deploy the job, you must first build a container image for the job and push i
175175
176176
The image is now available in the container registry.
177177
178-
1. Create a job in the Container Apps environment.
178+
1. Create a job in the Container Apps environment:
179179
180180
```azurecli
181181
az containerapp job create \
@@ -201,11 +201,11 @@ To deploy the job, you must first build a container image for the job and push i
201201
--env-vars "AZURE_STORAGE_QUEUE_NAME=$QUEUE_NAME" "AZURE_STORAGE_CONNECTION_STRING=secretref:connection-string-secret"
202202
```
203203
204-
The following table describes the key parameters used in the command.
204+
The following table describes the key parameters used in the previous command.
205205
206206
| Parameter | Description |
207207
| --- | --- |
208-
| `--replica-timeout` | The maximum duration a replica can execute. |
208+
| `--replica-timeout` | The maximum duration a replica can run. |
209209
| `--min-executions` | The minimum number of job executions to run per polling interval. |
210210
| `--max-executions` | The maximum number of job executions to run per polling interval. |
211211
| `--polling-interval` | The polling interval at which to evaluate the scale rule. |
@@ -214,22 +214,22 @@ To deploy the job, you must first build a container image for the job and push i
214214
| `--scale-rule-metadata` | The metadata for the scale rule. |
215215
| `--scale-rule-auth` | The authentication for the scale rule. |
216216
| `--secrets` | The secrets to use for the job. |
217-
| `--registry-server` | The container registry server to use for the job. For an Azure Container Registry, the command automatically configures authentication. |
217+
| `--registry-server` | The container registry server to use for the job. For an Azure container registry, the command automatically configures authentication. |
218218
| `--mi-user-assigned` | The resource ID of the user-assigned managed identity to assign to the job. |
219-
| `--registry-identity` | The resource ID of a managed identity to authenticate with the registry server instead of using a username and password. If possible, an 'acrpull' role assignment is created for the identity automatically. |
219+
| `--registry-identity` | The resource ID of a managed identity to authenticate with the registry server instead of using a user name and password. If possible, an `acrpull` role assignment is automatically created for the identity. |
220220
| `--env-vars` | The environment variables to use for the job. |
221221
222-
The scale rule configuration defines the event source to monitor. It is evaluated on each polling interval and determines how many job executions to trigger. To learn more, see [Set scaling rules](scale-app.md).
222+
The scale rule configuration defines the event source to monitor. It's evaluated on each polling interval and determines how many job executions to trigger. For more information, see [Set scaling rules](scale-app.md).
223223
224224
The event-driven job is now created in the Container Apps environment.
225225
226226
## Verify the deployment
227227
228-
The job is configured to evaluate the scale rule every 60 seconds, which checks the number of messages in the queue. For each evaluation period, it starts a new job execution for each message in the queue, up to a maximum of 10 executions.
228+
The job is configured to evaluate the scale rule every 60 seconds. This evaluation checks the number of messages in the queue. For each evaluation period, it starts a new job execution for each message in the queue, up to a maximum of 10 executions.
229229
230-
To verify the job was configured correctly, you can send some messages to the queue, confirm that job executions are started, and the messages are logged to the job execution logs.
230+
To verify that the job is configured correctly, you can send some messages to the queue and confirm that job executions are started and that the messages are logged to the job execution logs.
231231
232-
1. Send a message to the queue.
232+
1. Send a message to the queue:
233233
234234
```azurecli
235235
az storage message put \
@@ -238,7 +238,7 @@ To verify the job was configured correctly, you can send some messages to the qu
238238
--connection-string "$QUEUE_CONNECTION_STRING"
239239
```
240240
241-
1. List the executions of a job.
241+
1. List the executions of a job:
242242
243243
```azurecli
244244
az containerapp job execution list \
@@ -247,9 +247,9 @@ To verify the job was configured correctly, you can send some messages to the qu
247247
--output json
248248
```
249249
250-
Since the job is configured to evaluate the scale rule every 60 seconds, it may take up to a full minute for the job execution to start. Repeat the command until you see the job execution and its status is `Succeeded`.
250+
Because the job is configured to evaluate the scale rule every 60 seconds, it might take up to a full minute for the job execution to start. Repeat the command until you see the job execution and its status is `Succeeded`.
251251
252-
1. Run the following commands to see logged messages. These commands require the Log analytics extension, so accept the prompt to install extension when requested.
252+
1. Run the following commands to see logged messages. These commands require the Log analytics extension, so accept the prompt to install the extension.
253253
254254
```azurecli
255255
LOG_ANALYTICS_WORKSPACE_ID=$(az containerapp env show --name $ENVIRONMENT --resource-group $RESOURCE_GROUP --query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId --output tsv)
@@ -262,21 +262,21 @@ To verify the job was configured correctly, you can send some messages to the qu
262262
Until the `ContainerAppConsoleLogs_CL` table is ready, the command returns an error: `BadArgumentError: The request had some invalid properties`. Wait a few minutes and try again.
263263
264264
> [!TIP]
265-
> Having issues? Let us know on GitHub by opening an issue in the [Azure Container Apps repo](https://github.com/microsoft/azure-container-apps).
265+
> Having problems? Let us know on GitHub by opening an issue in the [Azure Container Apps repo](https://github.com/microsoft/azure-container-apps).
266266
267267
## Clean up resources
268268
269-
Once you're done, run the following command to delete the resource group that contains your Container Apps resources.
269+
When you're done, run the following command to delete the resource group that contains your Container Apps resources.
270270
271271
>[!CAUTION]
272-
> The following command deletes the specified resource group and all resources contained within it. If resources outside the scope of this tutorial exist in the specified resource group, they will also be deleted.
272+
> The following command deletes the specified resource group and all resources contained in it. If there are resources outside the scope of this tutorial in the specified resource group, they're also deleted.
273273
274274
```azurecli
275275
az group delete \
276276
--resource-group $RESOURCE_GROUP
277277
```
278278

279-
## Next steps
279+
## Next step
280280

281281
> [!div class="nextstepaction"]
282282
> [Container Apps jobs](jobs.md)

0 commit comments

Comments
 (0)