Azure Container Apps health probes allow the Container Apps runtime to regularly inspect the status of your container apps.
You can set up probes using either TCP or HTTP(S) exclusively.
Container Apps supports the following probes:
Probe
Description
Startup
Checks if your application has successfully started. This check is separate from the liveness probe and executes during the initial startup phase of your application.
Liveness
Checks if your application is still running and responsive.
Readiness
Checks to see if a replica is ready to handle incoming requests.
For a full list of the probe specification supported in Azure Container Apps, refer to Azure REST API specs.
HTTP probes
HTTP probes allow you to implement custom logic to check the status of application dependencies before reporting a healthy status.
Configure your health probe endpoints to respond with an HTTP status code greater than or equal to 200 and less than 400 to indicate success. Any other response code outside this range indicates a failure.
The following example demonstrates how to implement a liveness endpoint in JavaScript.
const express = require('express');
const app = express();
app.get('/liveness', (req, res) => {
let isSystemStable = false;
// check for database availability
// check filesystem structure
// etc.
// set isSystemStable to true if all checks pass
if (isSystemStable) {
res.status(200); // Success
} else {
res.status(503); // Service unavailable
}
})
TCP probes
TCP probes wait to establish a connection with the server to indicate success. The probe fails if it can't establish a connection to your application.
Restrictions
You can only add one of each probe type per container.
exec probes aren't supported.
Port values must be integers; named ports aren't supported.
gRPC isn't supported.
Examples
The following code listing shows how you can define health probes for your containers.
The optional failureThreshold setting defines the number of attempts Container Apps tries to execute the probe if execution fails. Attempts that exceed the failureThreshold amount cause different results for each probe type.
Default configuration
If ingress is enabled, the following default probes are automatically added to the main app container if none is defined for each type.
Probe type
Default values
Startup
Protocol: TCP Port: ingress target port Timeout: 3 seconds Period: 1 second Initial delay: 1 second Success threshold: 1 Failure threshold: 240
If you're running your container app in multiple revision mode, after you deploy a revision, wait until your readiness probes indicate success before you shift traffic to that revision. In single revision mode, traffic is shifted automatically once the readiness probe returns a successful state.
A revision state appears as unhealthy if any of its replicas fails its readiness probe check, even if all other replicas in the revision are healthy. Container Apps restarts the replica in question until it is healthy again or the failure threshold is exceeded. If the failure threshold is exceeded, try restarting the revision, but it might mean the revision is not configured correctly.
If your app takes an extended amount of time to start (which is common in Java) you often need to customize the probes so your container doesn't crash.
The following example demonstrates how to configure the liveness and readiness probes in order to extend the startup times.
This module guides users through creating, configuring, and managing Container Apps and their environments. It also explores ingress options, scaling, instance management, and security considerations with best practices for configuring Azure Container Apps.