Lesson 1 of 2 Monitoring and Troubleshooting Container Workloads

Troubleshooting Azure Container Apps

This lesson explains where Container Apps records evidence, how to read revision status, how to recognize common failures and how to test connectivity.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish console logs from system logs.
  • Interpret revision running statuses.
  • Identify the signatures of common failures.
  • Describe how to test connectivity from inside a replica.

Sources of evidence

Container Apps produces two kinds of log, and they answer different questions. Console logs are what the application writes to standard output and standard error: stack traces, request logs, messages from the code. System logs are written by the platform: image pulls, revision provisioning, replica scheduling, probe failures, scaling decisions and container exits. A container that never starts produces no console logs at all, so system logs are the place to begin when a revision fails.

Both kinds of log can be streamed live from the command line and are also sent to the environment's log destination. With a Log Analytics workspace as the destination, console logs appear in the ContainerAppConsoleLogs_CL table and system logs in ContainerAppSystemLogs_CL; when logs are routed through Azure Monitor diagnostic settings, the equivalent tables are ContainerAppConsoleLogs and ContainerAppSystemLogs. Metrics such as replica count, requests and CPU are available in Azure Monitor, and the portal's Diagnose and solve problems page runs automated checks.

az containerapp revision list --resource-group RG --name orders-api -o table
az containerapp logs show --resource-group RG --name orders-api --type system --tail 50
az containerapp logs show --resource-group RG --name orders-api --type console --follow
az containerapp exec --resource-group RG --name orders-api --command /bin/sh
Sort into groups

Console or system log?

Exam skills 1.2.4

Decide which kind of Container Apps log records each event.

Log in to try this activity Interactive activities are free with an account.

Revision and replica status

Each revision reports a provisioning status (Provisioning, Provisioned or Provisioning failed) and a running status. The running statuses describe what the replicas are doing, and several of them point directly to a cause.

Running statusMeaningUsual next step
ActivatingNo replicas yet; the first is being provisionedWait, then check system logs if it persists
Activation failedThe first replica failed to startSystem logs: image pull, port or probe errors
Scale to 0No replicas and none being createdNormal for an idle app with minimum 0
DegradedAt least one replica is in a failed stateSystem and console logs of the failing replica
FailedCritical errors, such as repeated termination or exit code 137Check memory allocation and the application's start-up

Exit code 137 means the container was killed, most often because it exceeded its memory allocation; the fix is a larger CPU and memory combination or a smaller memory footprint, not a code change in the request path.

Match the pairs

Running statuses

Exam skills 1.2.4

Match each revision running status with what it means.

Log in to try this activity Interactive activities are free with an account.

Recognizing common failures

Most failed revisions fall into a small number of patterns, each with a recognizable signature in the system logs.

  • Image pull failure: the image name or tag is wrong, or the app's identity lacks AcrPull, or the registry is not listed in the app's registry configuration.
  • Target port mismatch: ingress targets port 80 but the container listens on 8000, so start-up probes fail and the revision never becomes ready.
  • Probe failure: a health endpoint that returns errors or responds slowly, often while a model loads; a startup probe with a longer threshold fixes slow starts.
  • Crash at start-up: a missing environment variable or secret, or an exception in initialization; the console logs show the traceback.
  • Secret resolution failure: a Key Vault reference whose identity lacks Key Vault Secrets User, so the app cannot start.

The following diagram links the evidence for a Container Apps revision that failed to activate to its cause and the fix.

Diagnosing a Container Apps revision that shows Activation failed. Empty console logs and system-log probe failures on port 80 show that the container started but nothing answered where the platform looked: ingress targets port 80 while Gunicorn listens on 8000. Changing the ingress target port to 8000, an application-scope setting, fixes the revision without a code change.
The previous revision keeps serving while the new one fails.

A failed deployment can look healthy

When a deployment fails in single revision mode, the previous revision keeps serving traffic. The app still works, which can hide the failure; always check the new revision's status after a deployment rather than only testing the URL.

Troubleshooting

Failed revisions

Exam skills 1.2.4

Find the cause of each failed Container Apps revision, choosing again until you find the fix.

Log in to try this activity Interactive activities are free with an account.

Testing end-to-end connectivity

Connectivity problems arise between the client and the app, and between the app and its dependencies. From outside, check the ingress type (an internal app has no public endpoint), IP restrictions, custom domain and certificate settings, and whether HTTP requests are redirected to HTTPS. Inside the environment, apps call each other by app name, such as http://orders-api, only when the target has ingress enabled.

For outbound problems, az containerapp exec opens a shell in a running replica, from which commands such as nslookup and curl test whether a database, cache or model endpoint resolves and responds. In an environment integrated with a virtual network, failures often come from DNS (a private endpoint's private DNS zone not linked to the virtual network), network security group rules or a firewall that blocks outbound traffic.

Select all that apply

Connectivity checks

Exam skills 1.2.4

Identify the likely causes of a connectivity problem.

Log in to try this activity Interactive activities are free with an account.
Worked example

A revision that never becomes ready

After a deployment, a container app's new revision shows Activation failed, while the previous revision continues to serve. The console logs for the new revision are empty. The system logs show repeated probe failures on port 80. The image's Dockerfile ends with a command that starts Gunicorn on port 8000.

Empty console logs and probe failures indicate that the container probably started but nothing answered where the platform was looking. The ingress target port is 80 while the application listens on 8000. Updating the ingress target port to 8000 fixes the revision. Because ingress is an application-scope setting, the change applies without a code change.

Adding more CPU would not change the port. Switching to multiple revision mode would only keep both revisions active. Rebuilding the image without a code change would produce the same result.

Check yourself

A revision shows Failed and the system logs report exit code 137. What does that usually mean?

Show answer

The container was killed, most often for exceeding its memory allocation. A larger CPU and memory combination or a smaller memory footprint is the fix.

Exam Tips

Remember for the exam

  • Console logs show application output; system logs show platform events such as pulls and probes.
  • Log Analytics tables: ContainerAppConsoleLogs_CL and ContainerAppSystemLogs_CL.
  • Activation failed with empty console logs often means an image pull, port or probe problem.
  • Use az containerapp exec to test DNS and connections from inside a replica.