Skip to content

Commit 531eb5b

Browse files
authored
Merge pull request #311143 from v-albemi/sessions
Freshness Edit: Azure Container Apps
2 parents 0d9e7e3 + 29c164f commit 531eb5b

1 file changed

Lines changed: 52 additions & 53 deletions

File tree

articles/container-apps/sessions-code-interpreter.md

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: Serverless code interpreter sessions in Azure Container Apps
3-
description: Learn to run a serverless code interpreter session in Azure Container Apps.
2+
title: Serverless Code Interpreter Sessions in Azure Container Apps
3+
description: Learn how to run a serverless code interpreter session in Azure Container Apps.
44
services: container-apps
55
author: craigshoemaker
66
ms.service: azure-container-apps
77
ms.topic: how-to
8-
ms.date: 05/19/2025
8+
ms.date: 01/30/2026
99
ms.update-cycle: 180-days
1010
ms.author: cshoe
1111
ms.custom: references_regions
@@ -14,91 +14,90 @@ ms.collection: ce-skilling-ai-copilot
1414

1515
# Serverless code interpreter sessions in Azure Container Apps
1616

17-
Azure Container Apps [dynamic sessions](sessions.md) provides fast and scalable access to a code interpreter. Each code interpreter session is fully isolated by a Hyper-V boundary and is designed to run untrusted code.
17+
Azure Container Apps [dynamic sessions](sessions.md) provide fast and scalable access to a code interpreter. Each code interpreter session is fully isolated by a Hyper-V boundary and is designed to run untrusted code.
1818

1919
## Uses for code interpreter sessions
2020

21-
Code interpreter sessions are ideal for scenarios where you need to run code that is potentially malicious or could cause harm to the host system or other users, such as:
21+
Code interpreter sessions are ideal for scenarios where you need to run code that's potentially malicious or could cause harm to the host system or other users, such as:
2222

2323
- Code generated by a large language model (LLM).
2424
- Code submitted by an end user in a web or SaaS application.
2525

26-
For popular LLM frameworks such as LangChain, LlamaIndex, or Semantic Kernel, you can use [tools and plugins](#llm-framework-integrations) to integrate AI apps with code interpreter sessions.
26+
For popular LLM frameworks such as LangChain, LlamaIndex, and Semantic Kernel, you can use [tools and plugins](#llm-framework-integrations) to integrate AI apps with code interpreter sessions.
2727

28-
Your applications can also integrate with code interpreter session using a [REST API](#management-api-endpoints). The API allows you to:
28+
Your applications can also integrate with code interpreter session by using a [REST API](#management-api-endpoints). The API enables you to:
2929

30-
- Execute code in a session and retrieve results
30+
- Run code in a session and retrieve results.
3131
- Upload and download files to and from the session.
3232

33-
You can upload and download executable code files, or data files that your code can process.
33+
You can upload and download executable code files or data files that your code can process.
3434

35-
The built-in code interpreter sessions support the most common code execution scenarios without the need to manage infrastructure or containers.
35+
The built-in code interpreter sessions support the most common code execution scenarios without requiring you to manage infrastructure or containers.
3636

3737
If you need full control over the code execution environment or have a different scenario that requires isolated sandboxes, you can use [custom code interpreter sessions](sessions-custom-container.md).
3838

3939
## Code interpreter session pool
4040

4141
To use code interpreter sessions, you need an Azure resource called a [session pool](session-pool.md) that defines the configuration for code interpreter sessions.
4242

43-
In the session pool, you can specify settings such as the maximum number of concurrent sessions and how long a session can be idle before the session is terminated.
43+
In the session pool, you can specify settings such as the maximum number of concurrent sessions and how long a session can be idle before the session is stopped.
4444

45-
You can create a session pool using the Azure portal, Azure CLI, or Azure Resource Manager templates. After you create a session pool, you can use the pool's management API endpoints to manage and execute code inside a session.
45+
You can create a session pool by using the Azure portal, the Azure CLI, or Azure Resource Manager templates. After you create a session pool, you can use the pool's management API endpoints to manage and run code inside a session.
4646

4747
For more information about how to create and configure a session pool, see [Use session pools](./session-pool.md).
4848

4949
## Code execution in a session
5050

51-
After you create a session pool, your application can interact with sessions in the pool using an integration with an [LLM framework](#llm-framework-integrations) or by using the pool's [management API endpoints](#management-api-endpoints) directly.
51+
After you create a session pool, your application can interact with sessions in the pool by using an integration with an [LLM framework](#llm-framework-integrations) or by using the pool's [management API endpoints](#management-api-endpoints) directly.
5252

5353
## Session identifiers
5454

5555
> [!IMPORTANT]
56-
> The session identifier is sensitive information which requires you to use a secure process to manage its value. Part of this process requires that your application ensures each user or tenant only has access to their own sessions.
56+
> The session identifier is sensitive information. You need to use a secure process to manage its value. Part of this process is to make sure that your application ensures each user or tenant only has access to their own sessions.
5757
>
5858
> Failure to secure access to sessions could result in misuse or unauthorized access to data stored in your users' sessions. For more information, see [Session identifiers](sessions-usage.md#identifiers).
5959
60-
When you interact with sessions in a pool, you use a [session identifier](sessions-usage.md#identifiers) to reference each session A session identifier is a string that you define that is unique within the session pool. If you're building a web application, you can use the user's ID. If you're building a chatbot, you can use the conversation ID.
60+
When you interact with sessions in a pool, you use a [session identifier](sessions-usage.md#identifiers) to reference each session. A session identifier is a string that you define that's unique within the session pool. If you're building a web application, you can use the user's ID. If you're building a chatbot, you can use the conversation ID.
6161

6262
If there's a running session with the identifier, the session is reused. If there's no running session with the identifier, a new session is automatically created.
6363

6464
## Authentication
6565

66-
Authentication is handled using Microsoft Entra tokens. Valid Microsoft Entra tokens are generated by an identity belonging to the *Azure ContainerApps Session Executor* and *Contributor* roles on the session pool.
66+
Authentication is handled via Microsoft Entra tokens. Valid Microsoft Entra tokens are generated by an identity belonging to the *Azure ContainerApps Session Executor* and *Contributor* roles on the session pool.
6767

68-
If you're using an LLM framework integration, the framework handles the token generation and management for you. Ensure that the application is configured with a managed identity with the necessary role assignments on the session pool.
68+
If you're using an LLM framework integration, the framework handles the token generation and management for you. Ensure that the application is configured with a managed identity that has the necessary role assignments on the session pool.
6969

70-
If you're using the pool's management API endpoints directly, you must generate a token and include it in the `Authorization` header of your HTTP requests. In addition to the role assignments previously mentioned, token needs to contain an audience (`aud`) claim with the value `https://dynamicsessions.io`.
70+
If you're using the pool's management API endpoints directly, you must generate a token and include it in the `Authorization` header of your HTTP requests. In addition to the role assignments previously mentioned, token needs to contain an audience (`aud`) claim that has the value `https://dynamicsessions.io`.
7171

72-
To learn more, see [Authentication and authorization](sessions-usage.md#authentication).
72+
For more information, see [Authentication and authorization](sessions-usage.md#authentication).
7373

7474
## Work with files
7575

7676
You can upload and download files, and list all the files in a code interpreter session.
7777

7878
### Supported characters
7979

80-
Filenames and path must use only the following supported characters:
80+
File names and paths must use only the following supported characters:
8181

82-
- Uppercase and lowercase letters: `A-Z`, `a-z`
83-
- Digits: `0-9`
84-
- Special characters: `-`, `_`,` `, `.`, `@`, `$`, `&`, `=`, `;`, `,`, `#`, `%`, `^`, `(`, `)`
85-
- Unicode characters: Includes Chinese, Japanese, and other international characters
86-
- Path does not allow: `.`
82+
- Uppercase and lowercase letters: `A-Z`, `a-z`.
83+
- Digits: `0-9`.
84+
- Special characters: `-`, `_`,` `, `.`, `@`, `$`, `&`, `=`, `;`, `,`, `#`, `%`, `^`, `(`, `)`. (Paths can't contain `.`.)
85+
- Unicode characters: Includes Chinese, Japanese, and other international characters.
8786

8887
### Upload a file
8988

90-
To upload a file to a session, send a `POST` request to the `uploadFile` endpoint in a multipart form data request. Include the file data in the request body. The file must include a filename.
89+
To upload a file to a session, send a `POST` request to the `uploadFile` endpoint in a multipart form data request. Include the file data in the request body. The file must include a file name.
9190

92-
Uploaded files are stored in the session's file system under the `/mnt/data` directory.
91+
Uploaded files are stored in the session's file system in the `/mnt/data` directory.
9392

9493
The following example shows how to upload a file to a session.
9594

96-
Before you send the request, replace the placeholders between the `<>` brackets with values specific to your request.
95+
Before you send the request, replace the placeholders between the `<>` brackets with values that are specific to your request.
9796

9897
```http
9998
POST https://<REGION>.dynamicsessions.io/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/sessionPools/<SESSION_POOL_NAME>/files/upload?api-version=2024-02-02-preview&identifier=<SESSION_ID>
10099
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
101-
Authorization: Bearer <token>
100+
Authorization: Bearer <TOKEN>
102101
103102
------WebKitFormBoundary7MA4YWxkTrZu0gW
104103
Content-Disposition: form-data; name="file"; filename="<FILE_NAME_AND_EXTENSION>"
@@ -114,29 +113,29 @@ To download a file from a session's `/mnt/data` directory, send a `GET` request
114113

115114
The following example demonstrates how to format a `GET` request to download a file.
116115

117-
Before you send the request, replace the placeholders between the `<>` brackets with values specific to your request.
116+
Before you send the request, replace the placeholders between the `<>` brackets with values that are specific to your request.
118117

119118
```http
120119
GET https://<REGION>.dynamicsessions.io/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/sessionPools/<SESSION_POOL_NAME>/files/content/<FILE_NAME_AND_EXTENSION>?api-version=2024-02-02-preview&identifier=<SESSION_ID>
121120
Authorization: Bearer <TOKEN>
122121
```
123122

124-
### List the files
123+
### List files
125124

126125
To list the files in a session's `/mnt/data` directory, send a `GET` request to the `files` endpoint.
127126

128-
The following example shows you how to list the files in a session's directory.
127+
The following example shows how to list the files in a session's directory.
129128

130-
Before you send the request, replace the placeholders between the `<>` brackets with values specific to your request.
129+
Before you send the request, replace the placeholders between the `<>` brackets with values that are specific to your request.
131130

132131
```http
133132
GET https://<REGION>.dynamicsessions.io/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/sessionPools/<SESSION_POOL_NAME>/files?api-version=2024-02-02-preview&identifier=<SESSION_ID>
134133
Authorization: Bearer <TOKEN>
135134
```
136135

137-
The response contains a list of files in the session.
136+
The response contains a list of the files in the session.
138137

139-
The following listing shows a sample of the type of response you can expect from requesting session contents.
138+
The following listing shows a sample of the type of response you can expect when you request session contents.
140139

141140
```json
142141
{
@@ -166,11 +165,11 @@ The following listing shows a sample of the type of response you can expect from
166165

167166
## Security
168167

169-
Code interpreter sessions are designed to run untrusted code in isolated environments, ensuring that your applications and data remain protected.
168+
Code interpreter sessions are designed to run untrusted code in isolated environments to ensure that your applications and data remain protected.
170169

171170
## LLM framework integrations
172171

173-
Instead of using the session pool management API directly, the following LLM frameworks provide integrations with code interpreter sessions:
172+
Instead of using the session pool management API directly, you can use the following LLM frameworks, which provide integrations with code interpreter sessions.
174173

175174
| Framework | Package | Tutorial |
176175
|-----------|---------|------------|
@@ -180,11 +179,11 @@ Instead of using the session pool management API directly, the following LLM fra
180179

181180
## Management API endpoints
182181

183-
If you're not using an LLM framework integration, you can interact with the session pool directly using the [management API endpoints](session-pool.md#management-endpoint).
182+
If you're not using an LLM framework integration, you can interact with the session pool directly by using the [management API endpoints](session-pool.md#management-endpoint).
184183

185-
## Execute code in a session
184+
## Run code in a session
186185

187-
To execute code in a session, send a `POST` request to the `code/execute` endpoint with the code to run in the request body. Each code execution is limited to a maximum runtime of 220 seconds.
186+
To run code in a session, send a `POST` request to the `code/execute` endpoint with the code to run in the request body. Each code execution is limited to a maximum runtime of 220 seconds.
188187

189188
The following example prints `Hello, world!` in Python.
190189

@@ -193,7 +192,7 @@ Before you send the request, replace the placeholders between the `<>` brackets
193192
```http
194193
POST https://<REGION>.dynamicsessions.io/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/sessionPools/<SESSION_POOL_NAME>/code/execute?api-version=2024-02-02-preview&identifier=<SESSION_ID>
195194
Content-Type: application/json
196-
Authorization: Bearer <token>
195+
Authorization: Bearer <TOKEN>
197196
198197
{
199198
"properties": {
@@ -208,16 +207,16 @@ To reuse a session, specify the same session identifier in subsequent requests.
208207

209208
#### Upload a file to a session
210209

211-
To upload a file to a session, send a `POST` request to the `uploadFile` endpoint in a multipart form data request. Include the file data in the request body. The file must include a filename.
210+
To upload a file to a session, send a `POST` request to the `uploadFile` endpoint in a multipart form data request. Include the file data in the request body. The file must include a file name.
212211

213-
Uploaded files are stored in the session's file system under the `/mnt/data` directory.
212+
Uploaded files are stored in the session's file system in the `/mnt/data` directory.
214213

215-
Before you send the request, replace the placeholders between the `<>` brackets with values specific to your request.
214+
Before you send the request, replace the placeholders between the `<>` brackets with values that are specific to your request.
216215

217216
```http
218217
POST https://<REGION>.dynamicsessions.io/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/sessionPools/<SESSION_POOL_NAME>/files/upload?api-version=2024-02-02-preview&identifier=<SESSION_ID>
219218
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
220-
Authorization: Bearer <token>
219+
Authorization: Bearer <TOKEN>
221220
222221
------WebKitFormBoundary7MA4YWxkTrZu0gW
223222
Content-Disposition: form-data; name="file"; filename="<FILE_NAME_AND_EXTENSION>"
@@ -228,13 +227,13 @@ Content-Type: application/octet-stream
228227
```
229228

230229
> [!NOTE]
231-
> The file upload limit is `128MB`. If this is exceeded a `HTTP 413` may be returned.
230+
> The file upload limit is 128 MB. If this limit is exceeded, you might get an HTTP 413 error.
232231
233232
#### Download a file from a session
234233

235234
To download a file from a session's `/mnt/data` directory, send a `GET` request to the `file/content/{filename}` endpoint. The response includes the file data.
236235

237-
Before you send the request, replace the placeholders between the `<>` brackets with values specific to your request.
236+
Before you send the request, replace the placeholders between the `<>` brackets with values that are specific to your request.
238237

239238
```http
240239
GET https://<REGION>.dynamicsessions.io/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/sessionPools/<SESSION_POOL_NAME>/files/content/<FILE_NAME_AND_EXTENSION>?api-version=2024-02-02-preview&identifier=<SESSION_ID>
@@ -245,7 +244,7 @@ Authorization: Bearer <TOKEN>
245244

246245
To list the files in a session's `/mnt/data` directory, send a `GET` request to the `files` endpoint.
247246

248-
Before you send the request, replace the placeholders between the `<>` brackets with values specific to your request.
247+
Before you send the request, replace the placeholders between the `<>` brackets with values that are specific to your request.
249248

250249
```http
251250
GET https://<REGION>.dynamicsessions.io/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/sessionPools/<SESSION_POOL_NAME>/files?api-version=2024-02-02-preview&identifier=<SESSION_ID>
@@ -254,7 +253,7 @@ Authorization: Bearer <TOKEN>
254253

255254
The response contains a list of files in the session.
256255

257-
The following listing shows a sample of the type of response you can expect from requesting session contents.
256+
Following is an example of the type of response you can expect when you request session contents.
258257

259258
```json
260259
{
@@ -284,11 +283,11 @@ The following listing shows a sample of the type of response you can expect from
284283

285284
## Preinstalled packages
286285

287-
Python code interpreter sessions include popular Python packages such as *NumPy*, *pandas*, and *scikit-learn*.
286+
Python code interpreter sessions include popular Python packages such as NumPy, pandas, and scikit-learn.
288287

289288
To output the list of preinstalled packages, call the `code/execute` endpoint with the following code.
290289

291-
Before you send the request, replace the placeholders between the `<>` brackets with values specific to your request.
290+
Before you send the request, replace the placeholders between the `<>` brackets with values that are specific to your request.
292291

293292
```http
294293
POST https://<REGION>.dynamicsessions.io/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/sessionPools/<SESSION_POOL_NAME>/identifier/<SESSION_ID>/code/execute?api-version=2024-02-02-preview&identifier=<SESSION_ID>
@@ -306,13 +305,13 @@ Authorization: Bearer <TOKEN>
306305

307306
## Logging
308307

309-
Code interpreter sessions don't support logging directly. Your application that's interacting with the sessions can log requests to the session pool management API and its responses.
308+
Code interpreter sessions don't support logging directly. The application that's interacting with the sessions can log requests to the session pool management API and its responses.
310309

311310
## Billing
312311

313312
Code interpreter sessions are billed based on the duration of each session. For more information, see [Billing](billing.md#dynamic-sessions).
314313

315-
## Next steps
314+
## Next step
316315

317316
> [!div class="nextstepaction"]
318317
> [Use code interpreter sessions with LangChain](./sessions-tutorial-langchain.md)

0 commit comments

Comments
 (0)