Skip to content

Commit 2cd3607

Browse files
committed
Update jobs article
1 parent 79afbc5 commit 2cd3607

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

articles/container-apps/jobs.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: craigshoemaker
66
ms.service: container-apps
77
ms.custom: build-2023, devx-track-azurecli
88
ms.topic: conceptual
9-
ms.date: 08/17/2023
9+
ms.date: 02/28/2024
1010
ms.author: cshoe
1111
---
1212

@@ -33,12 +33,22 @@ The following table compares common scenarios for apps and jobs:
3333
| An HTTP server that serves web content and API requests | App | Configure an [HTTP scale rule](scale-app.md#http). |
3434
| A process that generates financial reports nightly | Job | Use the [*Schedule* job type](#scheduled-jobs) and configure a cron expression. |
3535
| A continuously running service that processes messages from an Azure Service Bus queue | App | Configure a [custom scale rule](scale-app.md#custom). |
36-
| A job that processes a single message or a small batch of messages from an Azure queue and exits | Job | Use the *Event* job type and [configure a custom scale rule](tutorial-event-driven-jobs.md) to trigger job executions. |
36+
| A job that processes a single message or a small batch of messages from an Azure queue and exits | Job | Use the *Event* job type and [configure a custom scale rule](tutorial-event-driven-jobs.md) to trigger job executions when there are messages in the queue. |
3737
| A background task that's triggered on-demand and exits when finished | Job | Use the *Manual* job type and [start executions](#start-a-job-execution-on-demand) manually or programmatically using an API. |
3838
| A self-hosted GitHub Actions runner or Azure Pipelines agent | Job | Use the *Event* job type and configure a [GitHub Actions](tutorial-ci-cd-runners-jobs.md?pivots=container-apps-jobs-self-hosted-ci-cd-github-actions) or [Azure Pipelines](tutorial-ci-cd-runners-jobs.md?pivots=container-apps-jobs-self-hosted-ci-cd-azure-pipelines) scale rule. |
3939
| An Azure Functions app | App | [Deploy Azure Functions to Container Apps](../azure-functions/functions-container-apps-hosting.md). |
4040
| An event-driven app using the Azure WebJobs SDK | App | [Configure a scale rule](scale-app.md#custom) for each event source. |
4141

42+
## Concepts
43+
44+
A Container Apps environment is a secure boundary around one or more container apps and jobs. Jobs involve a few key concepts:
45+
46+
* **Job:** A job defines the default configuration that is used for each job execution. The configuration includes the container image to use, the resources to allocate, and the command to run.
47+
* **Job execution:** A job execution is a single run of a job that is triggered manually, on a schedule, or in response to an event.
48+
* **Job replica:** A typical job execution runs one replica defined by the job's configuration. In advanced scenarios, a job execution can run multiple replicas.
49+
50+
:::image type="content" source="media/jobs/azure-container-apps-jobs-overview.png" alt-text="Azure Container Apps jobs overview":::
51+
4252
## Job trigger types
4353

4454
A job's trigger type determines how the job is started. The following trigger types are available:
@@ -49,7 +59,7 @@ A job's trigger type determines how the job is started. The following trigger ty
4959

5060
### Manual jobs
5161

52-
Manual jobs are triggered on-demand using the Azure CLI or a request to the Azure Resource Manager API.
62+
Manual jobs are triggered on-demand using the Azure CLI, Azure portal, or a request to the Azure Resource Manager API.
5363

5464
Examples of manual jobs include:
5565

@@ -66,7 +76,7 @@ To create a manual job using the Azure CLI, use the `az containerapp job create`
6676
az containerapp job create \
6777
--name "my-job" --resource-group "my-resource-group" --environment "my-environment" \
6878
--trigger-type "Manual" \
69-
--replica-timeout 1800 --replica-retry-limit 0 --replica-completion-count 1 --parallelism 1 \
79+
--replica-timeout 1800 \
7080
--image "mcr.microsoft.com/k8se/quickstart-jobs:latest" \
7181
--cpu "0.25" --memory "0.5Gi"
7282
```
@@ -141,7 +151,7 @@ Container Apps jobs use cron expressions to define schedules. It supports the st
141151
| `0 0 * * 0` | Runs every Sunday at midnight. |
142152
| `0 0 1 * *` | Runs on the first day of every month at midnight. |
143153

144-
Cron expressions in scheduled jobs are evaluated in Universal Time Coordinated (UTC).
154+
Cron expressions in scheduled jobs are evaluated in Coordinated Universal Time (UTC).
145155

146156
# [Azure CLI](#tab/azure-cli)
147157

@@ -151,7 +161,7 @@ To create a scheduled job using the Azure CLI, use the `az containerapp job crea
151161
az containerapp job create \
152162
--name "my-job" --resource-group "my-resource-group" --environment "my-environment" \
153163
--trigger-type "Schedule" \
154-
--replica-timeout 1800 --replica-retry-limit 0 --replica-completion-count 1 --parallelism 1 \
164+
--replica-timeout 1800 \
155165
--image "mcr.microsoft.com/k8se/quickstart-jobs:latest" \
156166
--cpu "0.25" --memory "0.5Gi" \
157167
--cron-expression "*/1 * * * *"
@@ -223,7 +233,7 @@ Event-driven jobs are triggered by events from supported [custom scalers](scale-
223233

224234
Container apps and event-driven jobs use [KEDA](https://keda.sh/) scalers. They both evaluate scaling rules on a polling interval to measure the volume of events for an event source, but the way they use the results is different.
225235

226-
In an app, each replica continuously processes events and a scaling rule determines the number of replicas to run to meet demand. In event-driven jobs, each job typically processes a single event, and a scaling rule determines the number of jobs to run.
236+
In an app, each replica continuously processes events and a scaling rule determines the number of replicas to run to meet demand. In event-driven jobs, each job execution typically processes a single event, and a scaling rule determines the number of job executions to run.
227237

228238
Use jobs when each event requires a new instance of the container with dedicated resources or needs to run for a long time. Event-driven jobs are conceptually similar to [KEDA scaling jobs](https://keda.sh/docs/latest/concepts/scaling-jobs/).
229239

@@ -237,7 +247,7 @@ To create an event-driven job using the Azure CLI, use the `az containerapp job
237247
az containerapp job create \
238248
--name "my-job" --resource-group "my-resource-group" --environment "my-environment" \
239249
--trigger-type "Event" \
240-
--replica-timeout 1800 --replica-retry-limit 0 --replica-completion-count 1 --parallelism 1 \
250+
--replica-timeout 1800 \
241251
--image "docker.io/myuser/my-event-driven-job:latest" \
242252
--cpu "0.25" --memory "0.5Gi" \
243253
--min-executions "0" \
@@ -341,13 +351,13 @@ To start a job execution using the Azure Resource Manager REST API, make a `POST
341351
The following example starts an execution of a job named `my-job` in a resource group named `my-resource-group`:
342352

343353
```http
344-
POST https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/my-resource-group/providers/Microsoft.App/jobs/my-job/start?api-version=2022-11-01-preview
354+
POST https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/my-resource-group/providers/Microsoft.App/jobs/my-job/start?api-version=2023-05-01
345355
Authorization: Bearer <TOKEN>
346356
```
347357

348358
Replace `<SUBSCRIPTION_ID>` with your subscription ID.
349359

350-
To authenticate the request, replace `<TOKEN>` in the `Authorization` header with a valid bearer token. For more information, see [Azure REST API reference](/rest/api/azure).
360+
To authenticate the request, replace `<TOKEN>` in the `Authorization` header with a valid bearer token. The identity used to generate the token must have `Contributor` permission to the Container Apps job resource. For more information, see [Azure REST API reference](/rest/api/azure).
351361

352362
# [Azure portal](#tab/azure-portal)
353363

@@ -357,6 +367,9 @@ To start a job execution in the Azure portal, select **Run now** in the job's ov
357367

358368
When you start a job execution, you can choose to override the job's configuration. For example, you can override an environment variable or the startup command to run the same job with different inputs. The overridden configuration is only used for the current execution and doesn't change the job's configuration.
359369

370+
> [!IMPORTANT]
371+
> When overriding the configuration, the job's entire template configuration is replaced with the new configuration. Ensure that the new configuration includes all required settings.
372+
360373
# [Azure CLI](#tab/azure-cli)
361374

362375
To override the job's configuration while starting an execution, use the `az containerapp job start` command and pass a YAML file containing the template to use for the execution. The following example starts an execution of a job named `my-job` in a resource group named `my-resource-group`.
@@ -367,6 +380,8 @@ Retrieve the job's current configuration with the `az containerapp job show` com
367380
az containerapp job show --name "my-job" --resource-group "my-resource-group" --query "properties.template" --output yaml > my-job-template.yaml
368381
```
369382

383+
The `--query "properties.template"` option returns only the job's template configuration.
384+
370385
Edit the `my-job-template.yaml` file to override the job's configuration. For example, to override the environment variables, modify the `env` section:
371386

372387
```yaml
@@ -397,7 +412,7 @@ az containerapp job start --name "my-job" --resource-group "my-resource-group" \
397412
To override the job's configuration, include a template in the request body. The following example overrides the startup command to run a different command:
398413

399414
```http
400-
POST https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/my-resource-group/providers/Microsoft.App/jobs/my-job/start?api-version=2022-11-01-preview
415+
POST https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/my-resource-group/providers/Microsoft.App/jobs/my-job/start?api-version=2023-05-01
401416
Content-Type: application/json
402417
Authorization: Bearer <TOKEN>
403418
@@ -421,7 +436,7 @@ Authorization: Bearer <TOKEN>
421436
}
422437
```
423438

424-
Replace `<SUBSCRIPTION_ID>` with your subscription ID and `<TOKEN>` in the `Authorization` header with a valid bearer token. For more information, see [Azure REST API reference](/rest/api/azure).
439+
Replace `<SUBSCRIPTION_ID>` with your subscription ID and `<TOKEN>` in the `Authorization` header with a valid bearer token. The identity used to generate the token must have `Contributor` permission to the Container Apps job resource. For more information, see [Azure REST API reference](/rest/api/azure).
425440

426441
# [Azure portal](#tab/azure-portal)
427442

@@ -446,7 +461,7 @@ az containerapp job execution list --name "my-job" --resource-group "my-resource
446461
To get the status of job executions using the Azure Resource Manager REST API, make a `GET` request to the job's `executions` operation. The following example returns the status of the most recent execution of a job named `my-job` in a resource group named `my-resource-group`:
447462

448463
```http
449-
GET https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/my-resource-group/providers/Microsoft.App/jobs/my-job/executions?api-version=2022-11-01-preview
464+
GET https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/my-resource-group/providers/Microsoft.App/jobs/my-job/executions?api-version=2023-05-01
450465
```
451466

452467
Replace `<SUBSCRIPTION_ID>` with your subscription ID.
@@ -469,7 +484,7 @@ Container Apps jobs support advanced configuration options such as container set
469484

470485
### Container settings
471486

472-
Container settings define the containers to run in each replica of a job execution. They include environment variables, secrets, and resource limits. For more information, see [Containers](containers.md).
487+
Container settings define the containers to run in each replica of a job execution. They include environment variables, secrets, and resource limits. For more information, see [Containers](containers.md). Running multiple containers in a single job is an advanced scenario. Most jobs run a single container.
473488

474489
### Job settings
475490

@@ -478,10 +493,11 @@ The following table includes the job settings that you can configure:
478493
| Setting | Azure Resource Manager property | CLI parameter| Description |
479494
|---|---|---|---|
480495
| Job type | `triggerType` | `--trigger-type` | The type of job. (`Manual`, `Schedule`, or `Event`) |
481-
| Parallelism | `parallelism` | `--parallelism` | The number of replicas to run per execution. For most jobs, set the value to `1`. |
482-
| Replica completion count | `replicaCompletionCount` | `--replica-completion-count` | The number of replicas to complete successfully for the execution to succeed. For most jobs, set the value to `1`. |
483496
| Replica timeout | `replicaTimeout` | `--replica-timeout` | The maximum time in seconds to wait for a replica to complete. |
497+
| Polling interval | `pollingInterval` | `--polling-interval` | The time in seconds to wait between polling for events. Default is 30 seconds. |
484498
| Replica retry limit | `replicaRetryLimit` | `--replica-retry-limit` | The maximum number of times to retry a failed replica. To fail a replica without retrying, set the value to `0`. |
499+
| Parallelism | `parallelism` | `--parallelism` | The number of replicas to run per execution. For most jobs, set the value to `1`. |
500+
| Replica completion count | `replicaCompletionCount` | `--replica-completion-count` | The number of replicas to complete successfully for the execution to succeed. Most be equal or or less than the parallelism. For most jobs, set the value to `1`. |
485501

486502
### Example
487503

112 KB
Loading

0 commit comments

Comments
 (0)