Introduction
In modern cloud-native application design, running background tasks, scheduled jobs, or event-driven batch processes is a common need. Traditionally, developers would use virtual machines, aca jobs, web jobs, Azure Functions, or Kubernetes Jobs to handle these workloads. However, managing infrastructure, scaling, and retries for such tasks often added operational complexity. To solve this, Microsoft introduced Azure Container Apps Jobs, giving developers a serverless, container-based, and event-driven approach for running ephemeral workloads without the need to manage infrastructure or a full Kubernetes cluster.
In this blog, we’ll explore what Azure Container Apps Jobs are, how they work, use cases, how they differ from regular ACA apps, and how you can create and run them using Azure CLI.
What are Azure Container Apps Jobs?
At its core, Azure Container Apps Jobs are short-lived, run-to-completion container workloads. They are designed to execute a task, complete the process, and then shut down automatically. Unlike standard Azure Container Apps (which are typically long-running services like web APIs or microservices), jobs in ACA are transient and non-persistent.
This makes them ideal for scenarios like:
- Batch data processing
- File transformations
- Message queue processing
- Scheduled ETL jobs
- One-off database migrations
- On-demand maintenance tasks
The best part? You don’t need to provision VMs, manage pods, or handle Kubernetes Job manifests. Azure takes care of the orchestration and scaling behind the scenes.
Types of Azure Container Apps Jobs
Azure Container Apps Jobs support three main execution modes, each designed for different triggering mechanisms:
- Manual (On-Demand Jobs):
These jobs are triggered manually using CLI, REST API, or automation scripts. Ideal for ad-hoc or operator-triggered workloads like running one-time database cleanup. - Scheduled Jobs:
These jobs run on a predefined schedule using CRON expressions. Think of it like Azure Functions Timer Trigger or scheduled tasks in a VM, but containerized and serverless. - Event-driven Jobs:
These jobs scale and run automatically in response to external event sources (like queue messages, Service Bus, or storage queues), leveraging KEDA ScaledJobs internally. The job execution count scales based on the volume of incoming events.
💡 Note: ACA Jobs use KEDA ScaledJobs under the hood for event-driven execution.
Key Features of ACA Jobs
| Feature | Description |
|---|---|
| Ephemeral execution | Jobs start, run to completion, and terminate |
| Parallel execution | Support for multiple concurrent job instances (controlled via parallelism settings) |
| Retry policies | Configure retries for failed executions |
| Timeout control | Define max execution time for each job replica |
| Scale-to-zero | No running resources when job is idle |
| Event-driven or Scheduled triggers | Flexible initiation options |
How Azure Container Apps Jobs Differ from Regular Container Apps
One common confusion is: When should I use an ACA Job instead of a regular ACA app?
Here’s the distinction:
| Feature | ACA Job | Regular ACA App |
|---|---|---|
| Execution pattern | Runs-to-completion | Long-running (always on or scaled) |
| Trigger types | Manual, Scheduled, Event-driven | Mostly HTTP or continuous background |
| Auto scale-to-zero after completion | Yes | Only in event-driven Container Apps |
| Suitable for | Batch tasks, ETL, queue processing | APIs, microservices, webhooks |
So, if your workload is short-lived and needs to run in reaction to an event or on a schedule, ACA Jobs are the way to go.
How ACA Jobs Work Behind the Scenes (The Role of KEDA)
For event-driven jobs, ACA internally uses KEDA ScaledJobs.
This means when an event source (like an Azure Service Bus queue) exceeds a certain threshold (say, 100 messages), ACA automatically:
- Triggers multiple job executions (depending on your parallelism settings).
- Spins up new job replicas.
- Monitors job completions and retries failed ones based on your defined retry policy.
- Tears down replicas after successful completion.
All this happens without you managing any Kubernetes resources.
Creating an Azure Container Apps Job: Step-by-Step
Let’s now walk through how you can create and run an ACA Job using the Azure CLI.
Step 1: Create a Resource Group and Container Apps Environment
az group create --name my-rg --location eastus
az containerapp env create \
--name my-aca-env \
--resource-group my-rg \
--location eastus
Step 2: Create an Event-driven Job (Example: Service Bus Queue Trigger)
This job will run whenever there are more than 10 messages in an Azure Service Bus queue.
az containerapp job create \
--name queue-worker-job \
--resource-group my-rg \
--environment my-aca-env \
--image myregistry.azurecr.io/worker:latest \
--trigger-type event \
--parallelism 5 \
--replica-timeout 300 \
--scale-rule-name sb-trigger \
--scale-rule-type azure-servicebus \
--scale-rule-metadata queueName=myqueue namespace=my-namespace messageCount=10
Step 3: Create a Scheduled Job (Example: Run Every Night at 1 AM UTC)
az containerapp job create \
--name nightly-job \
--resource-group my-rg \
--environment my-aca-env \
--image myregistry.azurecr.io/batchjob:latest \
--trigger-type schedule \
--replica-timeout 600 \
--cron-expression "0 1 * * *"
This job will run every day at 1 AM UTC, execute the container, and stop after completion.
Step 4: Manually Trigger an On-Demand Job
For ad-hoc jobs:
az containerapp job start \
--name one-time-task \
--resource-group my-rg
This starts the job immediately.
Important Job Configuration Parameters
When creating ACA Jobs, here are some crucial settings you’ll often configure:
| Parameter | Description |
|---|---|
--parallelism | Max number of job replicas that can run in parallel |
--replica-timeout | Max execution time allowed per job instance (in seconds) |
--replica-retry-limit | Number of times a failed job instance will retry |
--trigger-type | Options: manual, schedule, event |
--cron-expression | CRON format for scheduled jobs |
--scale-rule-metadata | Specific metadata for event triggers (e.g., queue name, namespace) |
Real-World Use Case Scenarios for ACA Jobs
| Scenario | Job Type |
|---|---|
| Process new orders from a Service Bus queue | Event-driven Job |
| Generate daily sales reports | Scheduled Job |
| Run ad-hoc maintenance tasks | Manual Job |
| ETL batch processing from data lake | Scheduled or Event-driven Job |
| Image resizing after upload event | Event-driven Job |
Conclusion:
Azure Container Apps Jobs bring a much-needed serverless batch-processing capability to Azure’s container ecosystem. They give you the power of containers with the simplicity of serverless execution, without managing any infrastructure or Kubernetes complexities.
Whether you need event-driven micro-batch jobs, scheduled container runs, or ad-hoc maintenance tasks, ACA Jobs offer a clean, scalable, and fully managed solution.