Job Concepts
In Azure Batch, a Job defines a collection of work to be performed. Jobs group related tasks, control their execution order, and provide a central point for monitoring and management.
Job Lifecycle
The lifecycle consists of the following states:
- Active – The job is ready to accept tasks.
- Running – At least one task is executing.
- Completed – All tasks have finished successfully or failed.
- Terminating – The job is being cancelled or deleted.
Show example: Creating a job with Azure CLI
# Create a new job
az batch job create \\
--account-name MyBatchAccount \\
--resource-group MyResourceGroup \\
--id my-job \\
--pool-id my-pool
Job Properties
| Property | Type | Description |
|---|---|---|
| id | string | Unique identifier for the job. |
| displayName | string | Friendly name shown in the portal. |
| priority | int | Execution priority, higher values mean higher priority. |
| state | enum | Current state (active, running, completed, etc.). |
| constraints | object | Timeouts and retry limits. |
| metadata | array | Custom key/value pairs. |
Job Scheduling
Jobs can be scheduled to start at a specific time or recur on a defined interval.
Show example: Recurring job with SDK (Python)
import azure.batch as batch
from datetime import datetime, timedelta
client = batch.BatchServiceClient(credentials, batch_url)
recurrence = batch.models.RecurrenceInterval(
interval=timedelta(hours=6)
)
schedule = batch.models.Schedule(
start_window=datetime.utcnow(),
recurrence=recurrence
)
client.job.add(
job_id='recurring-job',
pool_info=batch.models.PoolInformation(pool_id='my-pool'),
schedule=schedule
)