Skip to content

Commit f8d37c3

Browse files
committed
Add probes and stop session guidance
1 parent 4591030 commit f8d37c3

1 file changed

Lines changed: 120 additions & 0 deletions

File tree

articles/container-apps/sessions-custom-container.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ ms.collection: ce-skilling-ai-copilot
1717

1818
In addition to the built-in code interpreter that Azure Container Apps dynamic sessions provide, you can also use custom containers to define your own session sandboxes.
1919

20+
> [!NOTE]
21+
> This article applies only to custom container session pools. Unless noted, features described here aren't available for code interpreter session pools.
22+
2023
## Uses for custom container sessions
2124

2225
Custom containers allow you to build solutions tailored to your needs. They enable you to execute code or run applications in environments that are fast and ephemeral and offer secure, sandboxed spaces with Hyper-V. Additionally, they can be configured with optional network isolation. Some examples include:
@@ -31,6 +34,123 @@ To use custom container sessions, you first create a session pool with a custom
3134

3235
When your application requests a session, an instance is instantly allocated from the pool. The session remains active until it enters an idle state, which is then automatically stopped and destroyed.
3336

37+
## Container probes for session pools
38+
39+
Use container probes to configure health checks for custom container session pools and maintain healthy session instances.
40+
41+
> [!NOTE]
42+
> Container probes require API version `2025-02-02-preview` or later.
43+
44+
Container probes let you define health checks for session containers, similar to health probes in Azure Container Apps. When configured, the session pool monitors each session instance and removes unhealthy instances.
45+
46+
The session pool:
47+
48+
- Ensures ready session instances are healthy based on the probes.
49+
- Automatically removes unhealthy session instances.
50+
- Scales up to maintain the configured `readySessionInstances` count with healthy sessions.
51+
52+
Session pools support **Liveness** and **Startup** probe types. For more information about how probes work, see [Health probes in Azure Container Apps](health-probes.md?tabs=arm-template).
53+
54+
### Configuration
55+
56+
When you create or update a session pool, specify probes in the `properties.customContainerTemplate.containers` section of your request payload.
57+
58+
For the full API specification, see [SessionPools API](/rest/api/resource-manager/containerapps/container-apps-session-pools/create-or-update?view=rest-resource-manager-containerapps-2025-07-01&tabs=HTTP).
59+
60+
#### Example
61+
62+
```json
63+
{
64+
"properties": {
65+
"customContainerTemplate": {
66+
"containers": [
67+
{
68+
"name": "my-session-container",
69+
"image": "myregistry.azurecr.io/my-session-image:latest",
70+
"probes": [
71+
{
72+
"type": "Liveness",
73+
"httpGet": {
74+
"path": "/health",
75+
"port": 8080
76+
},
77+
"periodSeconds": 10,
78+
"failureThreshold": 3
79+
},
80+
{
81+
"type": "Startup",
82+
"httpGet": {
83+
"path": "/ready",
84+
"port": 8080
85+
},
86+
"periodSeconds": 5,
87+
"failureThreshold": 30
88+
}
89+
]
90+
}
91+
]
92+
},
93+
"dynamicPoolConfiguration": {
94+
"readySessionInstances": 5
95+
}
96+
}
97+
}
98+
```
99+
100+
### Troubleshooting
101+
102+
If your session pool isn't maintaining the expected number of healthy `readySessionInstances`, consider the following:
103+
104+
1. **Check container logs** - Review session container logs to identify issues with probe endpoints or container startup. See [View logs for custom container session pools](../code-interpreter/bring-your-own-code-interpreter/tutorials/custom-container-logs.md).
105+
2. **Verify probe configuration** - Ensure probe paths, ports, and thresholds are configured correctly for your application.
106+
3. **Review container health** - Check for issues inside your container that prevent probe endpoints from responding successfully.
107+
108+
## Stop a session
109+
110+
Use the Stop Session API to terminate a session in a custom container session pool.
111+
112+
113+
114+
Session pools support automatic session management through `lifecycleConfiguration`, which handles session lifecycle based on your configuration. However, there are scenarios where you may need more control.
115+
116+
After allocating a session, you can call this API to manually terminate it at any time. This is useful when:
117+
118+
- You need to clean up resources before a session reaches its time-to-live.
119+
- Your session pool has reached its maximum concurrent sessions limit and you need to free up capacity for new sessions.
120+
- A session has completed its work and you want to release resources immediately.
121+
122+
### API reference
123+
124+
#### Request
125+
126+
```http
127+
POST {PoolManagementEndpoint}/.management/stopSession?api-version=2025-02-02-preview&identifier={SessionIdentifier}
128+
```
129+
130+
#### Parameters
131+
132+
| Parameter | Type | Required | Description |
133+
| --- | --- | --- | --- |
134+
| `api-version` | string | Yes | The API version to use (for example, `2025-02-02-preview`). |
135+
| `identifier` | string | Yes | The unique identifier of the session to stop. |
136+
137+
### Examples
138+
139+
#### Request
140+
141+
```http
142+
POST https://{PoolManagementEndpoint}/.management/stopSession?api-version=2025-02-02-preview&identifier=testSessionIdentifier
143+
```
144+
145+
#### Response
146+
147+
```text
148+
HTTP/1.1 200 OK
149+
Content-Type: text/plain
150+
151+
Session testSessionIdentifier in session pool testSessionPool stopped.
152+
```
153+
34154
## Logging
35155

36156
Custom container session pools integrate with Azure Monitor and Log Analytics. Application logs are captured only if your container writes output to `stdout` or `stderr`, so make sure your app emits logs to the console.

0 commit comments

Comments
 (0)