You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/container-apps/sessions-code-interpreter.md
+200-1Lines changed: 200 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ services: container-apps
5
5
author: craigshoemaker
6
6
ms.service: azure-container-apps
7
7
ms.topic: how-to
8
-
ms.date: 02/19/2025
8
+
ms.date: 04/07/2025
9
9
ms.author: cshoe
10
10
ms.custom: references_regions
11
11
ms.collection: ce-skilling-ai-copilot
@@ -70,6 +70,205 @@ If you're using the pool's management API endpoints directly, you must generate
70
70
71
71
To learn more, see [Authentication and authorization](sessions-usage.md#authentication).
72
72
73
+
## Work with files
74
+
75
+
You can upload and download files, and list all the files in a code interpreter session.
76
+
77
+
### Upload a file
78
+
79
+
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.
80
+
81
+
Uploaded files are stored in the session's file system under the `/mnt/data` directory.
82
+
83
+
The following example shows how to upload a file to a session.
84
+
85
+
Before you send the request, replace the placeholders between the `<>` brackets with values specific to your request.
86
+
87
+
```http
88
+
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>
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.
103
+
104
+
The following example demonstrates how to format a `GET` request to download a file.
105
+
106
+
Before you send the request, replace the placeholders between the `<>` brackets with values specific to your request.
107
+
108
+
```http
109
+
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>
110
+
Authorization: Bearer <TOKEN>
111
+
```
112
+
113
+
### List the files
114
+
115
+
To list the files in a session's `/mnt/data` directory, send a `GET` request to the `files` endpoint.
116
+
117
+
The following example shows you how to list the files in a session's directory.
118
+
119
+
Before you send the request, replace the placeholders between the `<>` brackets with values specific to your request.
120
+
121
+
```http
122
+
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>
123
+
Authorization: Bearer <TOKEN>
124
+
```
125
+
126
+
The response contains a list of files in the session.
127
+
128
+
The following listing shows a sample of the type of response you can expect from requesting session contents.
Code interpreter sessions are designed to run untrusted code in isolated environments, ensuring that your applications and data remain protected.
159
+
160
+
### Use managed identity
161
+
162
+
A managed identity from Microsoft Entra ID allows your container session pools and their sessions to access other Microsoft Entra protected resources. Both system-assigned and user-assigned managed identities are supported in a session pool.
163
+
164
+
For more about managed identities in Microsoft Entra ID, see [Managed identities for Azure resources](../active-directory/managed-identities-azure-resources/overview.md).
165
+
166
+
There are two ways to use managed identities with custom container session pools:
167
+
168
+
-**Image pull authentication**: Use the managed identity to authenticate with the container registry to pull the container image.
169
+
170
+
-**Resource access**: Use the session pool's managed identity in a session to access other Microsoft Entra protected resources. Due to its security implications, this capability is disabled by default.
171
+
172
+
> [!IMPORTANT]
173
+
> If you enable access to managed identity in a session, any code or programs running in the session can create Microsoft Entra tokens for the pool's managed identity. Since sessions typically run untrusted code, use this feature with extreme caution.
174
+
175
+
# [Azure CLI](#tab/azure-cli)
176
+
177
+
To enable managed identity for a custom container session pool, use Azure Resource Manager.
178
+
179
+
# [Azure Resource Manager](#tab/arm)
180
+
181
+
To enable managed identity for a custom container session pool, you add an `identity` property to the session pool resource.
182
+
183
+
The `identity` property must have a `type` property with the value `SystemAssigned` or `UserAssigned`. For more information on how to configure this property, see [Configure managed identities](managed-identity.md?tabs=arm%2Cdotnet#configure-managed-identities).
184
+
185
+
The following example shows an ARM template snippet that enables a user-assigned identity for a custom container session pool and use it for image pull authentication.
186
+
187
+
Before you send the request, replace the placeholders between the `<>` brackets with the appropriate values for your session pool and session identifier.
This template contains the following settings for managed identity:
263
+
264
+
| Parameter | Value | Description |
265
+
|---------|-------|-------------|
266
+
|`customContainerTemplate.registryCredentials.identity`|`<IDENTITY_RESOURCE_ID>`| The resource ID of the managed identity to use for image pull authentication. |
267
+
|`managedIdentitySettings.identity`|`<IDENTITY_RESOURCE_ID>`| The resource ID of the managed identity to use in the session. |
268
+
|`managedIdentitySettings.lifecycle`|`None`| The session lifecycle where the managed identity is available.<br><br>- `None` (default): The session can't access the identity. This setting is only used for image pull.<br><br>- `Main`: In addition to image pull, the main session can also access the identity. **Use with caution.**|
269
+
270
+
---
271
+
73
272
## LLM framework integrations
74
273
75
274
Instead of using the session pool management API directly, the following LLM frameworks provide integrations with code interpreter sessions:
0 commit comments