Home / Azure

AzureTroubleshootingAdvanced

Azure Container Apps jobs failing or never starting: cron in UTC, replica timeouts, retries and event-driven triggers

Scheduled job didn't run, executions show Failed, or an event-driven job ignores a full queue. Read the execution history, find the replica error, and fix cron, timeout, retry and scale rule settings.

Deepak Bhardwaj8 min read

Applies toAzure Container Apps jobs (Manual, Schedule and Event triggers), Consumption and workload profiles environments, Azure CLI with the containerapp extension

The nightly export didn't land. The job page shows executions in Failed state, or no execution at all at the time you expected. Or an event-driven job sits idle while its queue grows. Container Apps jobs run containers to completion instead of serving traffic, so the failure modes are different from a container app: schedules, timeouts, retries and completion counts rather than ingress and probes.

Work through it in order: did an execution start, did its replicas start, did they finish in time with exit code 0.

Symptom to cause

Symptom Likely cause Fix
Scheduled job ran at the wrong hour Cron is evaluated in UTC Convert the schedule to UTC
No execution at all at the expected time Wrong trigger type or cron, or the job was just updated Check triggerType and cronExpression
Execution Failed after exactly 30 minutes Replica timeout (default 1800 seconds) Raise --replica-timeout or split the work
Execution Failed on the first error, no retry Retry limit is 0 by default Set --replica-retry-limit 1 or more
Replicas never start, image errors Registry credentials or identity missing Fix az containerapp job registry set
Container exits immediately Wrong command/args, missing env var or secret Check console logs for the replica
Event job ignores a full queue Scale rule metadata or auth wrong, --max-executions too low Fix the rule, auth and limits
Same work processed twice Retries or overlapping executions on non-idempotent code Make the job idempotent; check parallelism

Step 1: read the job definition

az containerapp job show -n job-nightly-export -g rg-apps \
  --query "{trigger:properties.configuration.triggerType, \
            timeout:properties.configuration.replicaTimeout, \
            retries:properties.configuration.replicaRetryLimit, \
            schedule:properties.configuration.scheduleTriggerConfig, \
            event:properties.configuration.eventTriggerConfig, \
            image:properties.template.containers[0].image, \
            state:properties.provisioningState}" -o json

Things to check in the output:

  • trigger is Schedule, Event or Manual. A Manual job never starts on its own, whatever else you set.
  • schedule.cronExpression is a standard five-field cron expression evaluated in UTC. 0 2 * * * runs at 02:00 UTC, not 02:00 local time.
  • timeout is in seconds. Each replica is killed when it reaches it and the execution is marked failed.
  • retries is how many times a failed replica is retried within the same execution.
  • schedule.parallelism and schedule.replicaCompletionCount (or the same fields under event) control how many replicas run and how many must succeed.

Tip

The definition can say "triggerType": "Schedule" and still never run if the cron expression isn't what you think. Paste it into a cron tool set to UTC and read the next few run times before blaming the platform.

Step 2: read the execution history

az containerapp job execution list -n job-nightly-export -g rg-apps \
  --query "[].{name:name, status:properties.status, start:properties.startTime, end:properties.endTime}" \
  -o table

Status values include Running, Succeeded, Failed and Stopped; check your CLI output for the full set. For one execution, including its template:

az containerapp job execution show -n job-nightly-export -g rg-apps \
  --job-execution-name job-nightly-export-28xk9q1 -o json

What the history tells you:

  • No row at the expected time: the trigger never fired. Go back to Step 1 (cron, trigger type) or, for event jobs, Step 5.
  • Failed, duration equals the replica timeout: the job is too slow or hung. See Step 4.
  • Failed within seconds: image pull, startup or an immediate crash. See Step 3.
  • Succeeded but no output: the container exited 0 without doing the work. That's a code or configuration bug; read the logs.

Execution history for scheduled and event-driven jobs keeps only the most recent 100 executions. For anything older, rely on Log Analytics.

Step 3: find the replica error

List the replicas of an execution, then pull their logs:

az containerapp job replica list -n job-nightly-export -g rg-apps \
  --execution job-nightly-export-28xk9q1 -o table

az containerapp job logs show -n job-nightly-export -g rg-apps \
  --container export --execution job-nightly-export-28xk9q1 --tail 200

replica list and logs show are preview commands in the containerapp extension, so their flags can change. Run az containerapp job logs show --help on your installed version. If they aren't available, query the environment's Log Analytics workspace:

ContainerAppSystemLogs_CL
| where TimeGenerated > ago(1d)
| where Log_s has "job-nightly-export" or ContainerGroupName_s startswith "job-nightly-export"
| project TimeGenerated, ContainerGroupName_s, Reason_s, Log_s
| order by TimeGenerated desc
ContainerAppConsoleLogs_CL
| where TimeGenerated > ago(1d)
| where ContainerGroupName_s startswith "job-nightly-export-28xk9q1"
| project TimeGenerated, ContainerGroupName_s, ContainerName_s, Log_s
| order by TimeGenerated asc

Table and column names depend on how logs are sent. The _CL tables with _s suffixes are used when the environment's logs destination is Log Analytics. Environments that use diagnostic settings write to ContainerAppConsoleLogs and ContainerAppSystemLogs with different column names. Run getschema on whichever table exists.

Common findings in system logs:

Log message contains Meaning Fix
ImagePullBackOff, unauthorized, manifest unknown Can't pull the image Fix the registry identity or tag (below)
Back-off restarting failed container or a non-zero exit code The process crashed Read console logs; check command, args and env vars
OOMKilled Memory limit hit Raise --memory or process data in smaller batches
Replica stopped at the timeout replicaTimeout reached Step 4

Registry access with a managed identity:

az containerapp job identity assign -n job-nightly-export -g rg-apps --system-assigned

PRINCIPAL=$(az containerapp job show -n job-nightly-export -g rg-apps --query identity.principalId -o tsv)
ACR_ID=$(az acr show -n acrprod --query id -o tsv)
az role assignment create --assignee "$PRINCIPAL" --role AcrPull --scope "$ACR_ID"

az containerapp job registry set -n job-nightly-export -g rg-apps \
  --server acrprod.azurecr.io --identity system

Step 4: timeouts, retries and completion

The defaults are a 1,800-second replica timeout, no retries, one replica, one required completion. They fit short jobs. For a batch that sometimes takes 45 minutes and should survive one transient failure:

az containerapp job update -n job-nightly-export -g rg-apps \
  --replica-timeout 3600 \
  --replica-retry-limit 2

Microsoft recommends a retry limit of at least 1 because platform maintenance can interrupt long-running replicas.

Warning

Retries rerun the whole container. If the job writes rows, sends emails or moves files, a retry after a partial run repeats that work. Make the job idempotent (upserts, checkpoints, "already processed" markers) before raising the retry limit on anything that touches production data.

With --parallelism 3 --replica-completion-count 3, the execution only succeeds when three replicas finish with exit code 0. If one keeps failing, the whole execution fails. Each replica must know which slice of the work it owns. Otherwise all three do the same work.

Run a one-off manual execution to test a fix without waiting for the schedule:

az containerapp job start -n job-nightly-export -g rg-apps

Stop a hung execution:

az containerapp job stop -n job-nightly-export -g rg-apps \
  --job-execution-name job-nightly-export-28xk9q1

Step 5: event-driven jobs that don't start

Event jobs use KEDA scalers. Every polling interval (30 seconds by default), KEDA checks the event source and starts executions, up to maxExecutions. Read the rule:

az containerapp job show -n job-queue-worker -g rg-apps \
  --query "properties.configuration.eventTriggerConfig" -o json

Check:

  • Metadata names and values. For an Azure Storage queue rule (azure-queue), the queue name and account name must match exactly. For Service Bus, check the queue or topic and subscription names. Metadata keys are scaler-specific and case-sensitive.
  • Scaler authentication. --scale-rule-auth maps a job secret to the scaler's auth parameter, for example connection=queue-conn. The secret must exist on the job:
az containerapp job secret list -n job-queue-worker -g rg-apps -o table
  • Limits. maxExecutions caps how many executions run at once. If each execution handles one message and the cap is low, the queue drains slowly but still drains.
  • Exit behaviour. Each execution should take its message(s), process them and exit. A worker that loops forever never completes. It runs until the replica timeout and fails, and the next execution starts against the same messages.

Fix a rule in place:

az containerapp job update -n job-queue-worker -g rg-apps \
  --min-executions 0 --max-executions 20 --polling-interval 30 \
  --scale-rule-name queue \
  --scale-rule-type azure-queue \
  --scale-rule-metadata "accountName=stjobsprod" "queueName=exports" "queueLength=1" \
  --scale-rule-auth "connection=queue-conn"

Managed identity auth for scalers (--scale-rule-identity) is in preview in the extension. Check az containerapp job update --help for your version.

Prevent it next time

  • Write cron expressions in UTC and put the local time in a comment or tag on the job.
  • Set --replica-timeout from measured run times plus headroom, not the default.
  • Set --replica-retry-limit to at least 1 for jobs that are idempotent, and make the rest idempotent.
  • Alert on failed executions. Use a log search alert on the system logs table, or a check that the job's expected output arrived.
  • Use a managed identity with AcrPull for the registry, so a rotated password can't stop the job.
  • Test changes with az containerapp job start straight after every update, instead of finding out at 02:00 UTC.