Skip to content

Commit fd2e69f

Browse files
Merge pull request #6520 from MicrosoftDocs/main
Auto Publish – main to live - 2025-08-11 22:05 UTC
2 parents 7ed5cd4 + 6978cf8 commit fd2e69f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+480
-453
lines changed

articles/ai-foundry/agents/concepts/model-region-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ All deployments can perform the exact same inference operations, however the bil
2525
Azure AI Foundry Agent Service supports the following Azure OpenAI models in the listed regions.
2626

2727
> [!NOTE]
28-
> * [Hub based projects](../../what-is-azure-ai-foundry.md#project-types) are limited to the following models: gpt-4o, gpt-4o-mini, gpt-4, gpt-35-turbo
28+
> * [Hub-based projects](../../what-is-azure-ai-foundry.md#project-types) are limited to the following models: gpt-4o, gpt-4o-mini, gpt-4, gpt-35-turbo
2929
> * For information on class A subnet support, see the setup guide on [GitHub](https://github.com/azure-ai-foundry/foundry-samples/tree/main/samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup).
3030
> * The [file search tool](../how-to/tools/file-search.md) is currently unavailable in the following regions:
3131
> * Italy north

articles/ai-foundry/agents/how-to/tools/code-interpreter-samples.md

Lines changed: 58 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Find code samples to enable code interpreter for Azure AI Agents.
55
author: aahill
66
ms.author: aahi
77
manager: nitinme
8-
ms.date: 06/30/2025
8+
ms.date: 08/11/2025
99
ms.service: azure-ai-agent-service
1010
ms.topic: how-to
1111
ms.custom:
@@ -146,161 +146,112 @@ This ensures proper resource management and prevents unnecessary resource consum
146146

147147
:::zone pivot="csharp"
148148

149-
## Create a project client
149+
## Create a client and agent
150150

151-
Create a client object, which will contain the project endpoint for connecting to your AI project and other resources.
151+
First, set up the configuration using `appsettings.json`, create a `PersistentAgentsClient`, and then create a `PersistentAgent` with the Code Interpreter tool enabled.
152152

153153
```csharp
154154
using Azure;
155155
using Azure.AI.Agents.Persistent;
156156
using Azure.Identity;
157+
using Microsoft.Extensions.Configuration;
158+
using System.Diagnostics;
157159

158-
var projectEndpoint = System.Environment.GetEnvironmentVariable("ProjectEndpoint");
159-
var projectEndpoint = System.Environment.GetEnvironmentVariable("ModelDeploymentName");
160-
var projectEndpoint = System.Environment.GetEnvironmentVariable("BingConnectionId");
160+
IConfigurationRoot configuration = new ConfigurationBuilder()
161+
.SetBasePath(AppContext.BaseDirectory)
162+
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
163+
.Build();
161164

162-
// Create the Agent Client
163-
PersistentAgentsClient agentClient = new(projectEndpoint, new DefaultAzureCredential());
164-
```
165-
166-
## Create an Agent with the Grounding with Bing search tool enabled
167-
168-
To make the Grounding with Bing search tool available to your agent, use a connection to initialize the tool and attach it to the agent. You can find your connection in the **connected resources** section of your project in the [Azure AI Foundry portal](https://ai.azure.com/?cid=learnDocs).
169-
170-
```csharp
165+
var projectEndpoint = configuration["ProjectEndpoint"];
166+
var modelDeploymentName = configuration["ModelDeploymentName"];
171167

172-
BingGroundingToolDefinition bingGroundingTool = new(
173-
new BingGroundingSearchToolParameters(
174-
[new BingGroundingSearchConfiguration(bingConnectionId)]
175-
)
176-
);
168+
PersistentAgentsClient client = new(projectEndpoint, new DefaultAzureCredential());
177169

178-
// Create the Agent
179-
PersistentAgent agent = agentClient.Administration.CreateAgent(
170+
PersistentAgent agent = client.Administration.CreateAgent(
180171
model: modelDeploymentName,
181-
name: "my-agent",
182-
instructions: "Use the bing grounding tool to answer questions.",
183-
tools: [bingGroundingTool]
172+
name: "My Friendly Test Agent",
173+
instructions: "You politely help with math questions. Use the code interpreter tool when asked to visualize numbers.",
174+
tools: [new CodeInterpreterToolDefinition()]
184175
);
185176
```
186177

187-
## Create a thread and run
178+
## Create a thread and add a message
179+
180+
Next, create a `PersistentAgentThread` for the conversation and add the initial user message.
188181

189182
```csharp
190-
PersistentAgentThread thread = agentClient.Threads.CreateThread();
183+
PersistentAgentThread thread = client.Threads.CreateThread();
191184

192-
// Create message and run the agent
193-
PersistentThreadMessage message = agentClient.Messages.CreateMessage(
185+
client.Messages.CreateMessage(
194186
thread.Id,
195187
MessageRole.User,
196-
"How does wikipedia explain Euler's Identity?");
197-
ThreadRun run = agentClient.Runs.CreateRun(thread, agent);
198-
188+
"Hi, Agent! Draw a graph for a line with a slope of 4 and y-intercept of 9.");
199189
```
200190

201-
## Wait for the agent to complete and print the output
191+
## Create and monitor a run
202192

203-
First, wait for the agent to complete the run by polling its status. Observe that the model uses the Grounding with Bing Search tool to provide a response to the user's question.
193+
Then, create a `ThreadRun` for the thread and agent. Poll the run's status until it completes or requires action.
204194

205195
```csharp
206-
// Wait for the agent to finish running
196+
ThreadRun run = client.Runs.CreateRun(
197+
thread.Id,
198+
agent.Id,
199+
additionalInstructions: "Please address the user as Jane Doe. The user has a premium account.");
200+
207201
do
208202
{
209203
Thread.Sleep(TimeSpan.FromMilliseconds(500));
210-
run = agentClient.Runs.GetRun(thread.Id, run.Id);
204+
run = client.Runs.GetRun(thread.Id, run.Id);
211205
}
212206
while (run.Status == RunStatus.Queued
213-
|| run.Status == RunStatus.InProgress);
214-
215-
// Confirm that the run completed successfully
216-
if (run.Status != RunStatus.Completed)
217-
{
218-
throw new Exception("Run did not complete successfully, error: " + run.LastError?.Message);
219-
}
207+
|| run.Status == RunStatus.InProgress
208+
|| run.Status == RunStatus.RequiresAction);
220209
```
221210

222-
Then, retrieve and process the messages from the completed run.
211+
## Process the results and handle files
212+
213+
Once the run is finished, retrieve all messages from the thread. Iterate through the messages to display text content and handle any generated image files by saving them locally and opening them.
223214

224215
```csharp
225-
// Retrieve all messages from the agent client
226-
Pageable<PersistentThreadMessage> messages = agentClient.Messages.GetMessages(
216+
Pageable<PersistentThreadMessage> messages = client.Messages.GetMessages(
227217
threadId: thread.Id,
228-
order: ListSortOrder.Ascending
229-
);
218+
order: ListSortOrder.Ascending);
230219

231-
// Process messages in order
232220
foreach (PersistentThreadMessage threadMessage in messages)
233221
{
234-
Console.Write($"{threadMessage.CreatedAt:yyyy-MM-dd HH:mm:ss} - {threadMessage.Role,10}: ");
235-
foreach (MessageContent contentItem in threadMessage.ContentItems)
222+
foreach (MessageContent content in threadMessage.ContentItems)
236223
{
237-
if (contentItem is MessageTextContent textItem)
224+
switch (content)
238225
{
239-
string response = textItem.Text;
240-
241-
// If we have Text URL citation annotations, reformat the response to show title & URL for citations
242-
if (textItem.Annotations != null)
243-
{
244-
foreach (MessageTextAnnotation annotation in textItem.Annotations)
226+
case MessageTextContent textItem:
227+
Console.WriteLine($"[{threadMessage.Role}]: {textItem.Text}");
228+
break;
229+
case MessageImageFileContent imageFileContent:
230+
Console.WriteLine($"[{threadMessage.Role}]: Image content file ID = {imageFileContent.FileId}");
231+
BinaryData imageContent = client.Files.GetFileContent(imageFileContent.FileId);
232+
string tempFilePath = Path.Combine(AppContext.BaseDirectory, $"{Guid.NewGuid()}.png");
233+
File.WriteAllBytes(tempFilePath, imageContent.ToArray());
234+
client.Files.DeleteFile(imageFileContent.FileId);
235+
236+
ProcessStartInfo psi = new()
245237
{
246-
if (annotation is MessageTextUriCitationAnnotation urlAnnotation)
247-
{
248-
response = response.Replace(urlAnnotation.Text, $" [{urlAnnotation.UriCitation.Title}]({urlAnnotation.UriCitation.Uri})");
249-
}
250-
}
251-
}
252-
Console.Write($"Agent response: {response}");
253-
}
254-
else if (contentItem is MessageImageFileContent imageFileItem)
255-
{
256-
Console.Write($"<image from ID: {imageFileItem.FileId}");
238+
FileName = tempFilePath,
239+
UseShellExecute = true
240+
};
241+
Process.Start(psi);
242+
break;
257243
}
258-
Console.WriteLine();
259244
}
260245
}
261-
262-
```
263-
264-
## Optionally output the run steps used by the agent
265-
266-
```csharp
267-
// Retrieve the run steps used by the agent and print those to the console
268-
Console.WriteLine("Run Steps used by Agent:");
269-
Pageable<RunStep> runSteps = agentClient.Runs.GetRunSteps(run);
270-
271-
foreach (var step in runSteps)
272-
{
273-
Console.WriteLine($"Step ID: {step.Id}, Total Tokens: {step.Usage.TotalTokens}, Status: {step.Status}, Type: {step.Type}");
274-
275-
if (step.StepDetails is RunStepMessageCreationDetails messageCreationDetails)
276-
{
277-
Console.WriteLine($" Message Creation Id: {messageCreationDetails.MessageCreation.MessageId}");
278-
}
279-
else if (step.StepDetails is RunStepToolCallDetails toolCallDetails)
280-
{
281-
// We know this agent only has the Bing Grounding tool, so we can cast it directly
282-
foreach (RunStepBingGroundingToolCall toolCall in toolCallDetails.ToolCalls)
283-
{
284-
Console.WriteLine($" Tool Call Details: {toolCall.GetType()}");
285-
286-
foreach (var result in toolCall.BingGrounding)
287-
{
288-
Console.WriteLine($" {result.Key}: {result.Value}");
289-
}
290-
}
291-
}
292-
}
293-
294246
```
295247

296248
## Clean up resources
297249

298-
Clean up the resources from this sample.
250+
Finally, delete the thread and the agent to clean up the resources created in this sample.
299251

300252
```csharp
301-
// Delete thread and agent
302-
agentClient.Threads.DeleteThread(threadId: thread.Id);
303-
agentClient.Administration.DeleteAgent(agentId: agent.Id);
253+
client.Threads.DeleteThread(threadId: thread.Id);
254+
client.Administration.DeleteAgent(agentId: agent.Id);
304255
```
305256

306257
:::zone-end
@@ -566,7 +517,6 @@ curl --request GET \
566517

567518
:::zone-end
568519

569-
570520
:::zone pivot="java"
571521

572522
## Download an example file

articles/ai-foundry/concepts/ai-resources.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: This article introduces concepts about Azure AI Foundry hubs for yo
55
ms.author: sgilley
66
author: sdgilley
77
ms.reviewer: deeikele
8-
ms.date: 04/28/2025
8+
ms.date: 08/11/2025
99
ms.service: azure-ai-foundry
1010
ms.topic: concept-article
1111
ms.custom:
@@ -20,9 +20,9 @@ ms.custom:
2020
# Hub resources overview
2121

2222
> [!NOTE]
23-
> You must use a **[!INCLUDE [hub](../includes/hub-project-name.md)]** for the features mentioned in this article. A **[!INCLUDE [fdp](../includes/fdp-project-name.md)]** is not supported. For more information, see [Project types](../what-is-azure-ai-foundry.md#which-type-of-project-do-i-need).
23+
> You must use a **[!INCLUDE [hub](../includes/hub-project-name.md)]** for the features mentioned in this article. A **[!INCLUDE [fdp](../includes/fdp-project-name.md)]** isn't supported. For more information, see [Project types](../what-is-azure-ai-foundry.md#which-type-of-project-do-i-need).
2424
25-
Azure AI Hub is a resource type that is used in combination with Azure AI Foundry resource type, and is only required for selected use cases. Hub resources provides access to open-source model hosting and finetuning capabilities, as well as Azure Machine Learning capabilities, next to capabilities supported by its associated AI Foundry resource.
25+
Azure AI Hub is a resource type that is used in combination with Azure AI Foundry resource type, and is only required for selected use cases. Hub resources provide access to open-source model hosting and fine-tuning capabilities, as well as Azure Machine Learning capabilities, next to capabilities supported by its associated AI Foundry resource.
2626

2727
When you create an AI Hub, an Azure AI Foundry resource is automatically provisioned. Hub resources can be used in [Azure AI Foundry](https://ai.azure.com/?cid=learnDocs) and [Azure Machine Learning studio](https://ml.azure.com).
2828

@@ -36,7 +36,7 @@ Hubs group one or more projects together with common settings including data acc
3636

3737
## Create a hub-based project
3838

39-
To start developing, [create a [!INCLUDE [hub-project-name](../includes/hub-project-name.md)]](../how-to/create-projects.md?pivots=hub-project). Hub-projects can be accessed in [AI Foundry Portal](https://ai.azure.com/?cid=learnDocs) to build with generative AI tools, and [ML Studio](https://ml.azure.com) to build with tools designed for custom machine learning model training.
39+
To start developing, [create a [!INCLUDE [hub-project-name](../includes/hub-project-name.md)]](../how-to/create-projects.md?pivots=hub-project). Hub-based projects can be accessed in [AI Foundry Portal](https://ai.azure.com/?cid=learnDocs) to build with generative AI tools, and [ML Studio](https://ml.azure.com) to build with tools designed for custom machine learning model training.
4040

4141
## Project concepts
4242

@@ -61,7 +61,7 @@ Projects also have specific settings that only hold for that project:
6161
6262
## Share configurations across projects using hub
6363

64-
A hub shares configurations for a group of projects. As a team lead, consider creating a hub for use cases that share the same security configurations or business domain to avoid repetitive setup and let developers create their own project against the pre-configured environment.
64+
A hub shares configurations for a group of projects. All projects in the hub share the same security configurations or business domain.
6565

6666
Shared configurations managed on the hub include:
6767
* **Security** including public network access, customer-managed key encryption, and identity controls. Security settings configured on the hub automatically pass down to each project. A managed virtual network is shared between all projects that share the same hub.
@@ -74,7 +74,7 @@ Shared configurations managed on the hub include:
7474

7575
Hubs let you manage connections to existing Azure OpenAI or Azure AI Foundry resources, so you can use their models and selected customization capabilities in hub-based projects.
7676

77-
After a connection is created, model deployments are accessible via playground experiences. When you use Finetuning experiences in a hub-based project, your finetuning jobs are implicitly executed on the connected AI Foundry resource (default project context).
77+
After a connection is created, model deployments are accessible via playground experiences. When you use Fine-tuning experiences in a hub-based project, your fine-tuning jobs are implicitly executed on the connected AI Foundry resource (default project context).
7878

7979
## Storage and Key Vault dependent resources
8080

articles/ai-foundry/concepts/fine-tuning-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ To find steps to fine-tuning a model in AI Foundry, see [Fine-tune Models in AI
9696

9797
Now that you know when to use fine-tuning for your use case, you can go to Azure AI Foundry to find models available to fine-tune.
9898

99-
**To fine-tune an AI Foundry model using Serverless** you must have a hub/project in the region where the model is available for fine tuning. See [Region availability for models in serverless API deployment](../how-to/deploy-models-serverless-availability.md) for detailed information on model and region availability, and [How to Create a Hub based project](../how-to/create-projects.md) to create your project.
99+
**To fine-tune an AI Foundry model using Serverless** you must have a hub/project in the region where the model is available for fine tuning. See [Region availability for models in serverless API deployment](../how-to/deploy-models-serverless-availability.md) for detailed information on model and region availability, and [How to Create a Hub-based project](../how-to/create-projects.md) to create your project.
100100

101101
**To fine-tune an OpenAI model** you can use an Azure OpenAI Resource, a Foundry resource or default project, or a hub/project. GPT 4.1, 4.1-mini and 4.1-nano are available in all regions with Global Training. For regional availability, see [Regional Availability and Limits for Azure OpenAI Fine Tuning](../openai/concepts/models.md). See [Create a project for Azure AI Foundry](../how-to/create-projects.md) for instructions on creating a new project.
102102

103-
**To fine-tune a model using Managed Compute** you must have a hub/project and available VM quota for training and inferencing. See [Fine-tune models using managed compute (preview)](../how-to/fine-tune-managed-compute.md) for more details on how to use managed compute fine tuning, and [How to Create a Hub based project](../how-to/create-projects.md) to create your project.
103+
**To fine-tune a model using Managed Compute** you must have a hub/project and available VM quota for training and inferencing. See [Fine-tune models using managed compute (preview)](../how-to/fine-tune-managed-compute.md) for more details on how to use managed compute fine tuning, and [How to Create a Hub-based project](../how-to/create-projects.md) to create your project.
104104

105105

106106
## Related content

articles/ai-foundry/concepts/management-center.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Use the management center to create and configure [!INCLUDE [FDP](../includes/fd
3838
For more information, see [Create a [!INCLUDE [fdp-project-name](../includes/fdp-project-name.md)]](../how-to/create-projects.md?pivots=fdp-project)
3939

4040

41-
### Manage Azure AI Foundry hubs and hub based projects
41+
### Manage Azure AI Foundry hubs and hub-based projects
4242

4343
You can also manage [!INCLUDE [hub](../includes/hub-project-name.md)]s from the management center. They're listed in the __All resources__ section, and when selected are displayed in the left menu.
4444

articles/ai-foundry/concepts/planning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to plan the rollout of Azure AI Foundry across your organ
55
ms.service: azure-ai-foundry
66
author: sdgilley
77
ms.topic: concept-article
8-
ms.date: 06/25/2025
8+
ms.date: 08/11/2025
99
ms.author: sgilley
1010
ms.reviewer: deeikele
1111
---

articles/ai-foundry/how-to/azure-policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ To control who can access your Azure AI Foundry hubs and projects, use [Microsof
7070
|---|---|---|
7171
| Azure AI Foundry App | cb2ff863-7f30-4ced-ab89-a00194bcf6d9 | Use to control access to the Azure AI Foundry portal. |
7272
| Azure Machine Learning Web App | d7304df8-741f-47d3-9bc2-df0e24e2071f | Use to control access to Azure Machine Learning studio. |
73-
| Azure Machine Learning | 0736f41a-0425-bdb5-1563eff02385 | Use to control direct access to the Azure Machine Learning API. For example, when using the SDK or REST API. Azure AI Foundry hub based projects rely on the Azure Machine Learning API. |
73+
| Azure Machine Learning | 0736f41a-0425-bdb5-1563eff02385 | Use to control direct access to the Azure Machine Learning API. For example, when using the SDK or REST API. Azure AI Foundry hub-based projects rely on the Azure Machine Learning API. |
7474

7575
## Configure built-in policies
7676

articles/ai-foundry/how-to/connections-add.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
title: Add a new connection to your project
44
titleSuffix: Azure AI Foundry
5-
description: Learn how to add a new connection to your hub based or Foundry project.
5+
description: Learn how to add a new connection to your hub-based or Foundry project.
66
ms.service: azure-ai-foundry
77
ms.custom:
88
- ignite-2023

articles/ai-foundry/how-to/data-add.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ A Table (`uri_table`) data source type points to a *table* on a storage resource
7878

7979
[!INCLUDE [tip-left-pane](../includes/tip-left-pane.md)]
8080

81-
These steps explain how to add an existing file, folder, or table data resource from Azure Storage to your hub based project workspace in the Azure AI Foundry portal:
81+
These steps explain how to add an existing file, folder, or table data resource from Azure Storage to your hub-based project workspace in the Azure AI Foundry portal:
8282

8383
1. Navigate to the [Azure AI Foundry](https://ai.azure.com/?cid=learnDocs).
8484

85-
1. Select the hub based project where you want to add the data.
85+
1. Select the hub-based project where you want to add the data.
8686

8787
1. From the collapsible **My assets** menu on the left, select **Data + indexes**, then select **New data** as shown in this screenshot:
8888

@@ -99,7 +99,7 @@ These steps explain how to add an existing file, folder, or table data resource
9999

100100
## Manage data
101101

102-
After you add data to your hub based project, you can you can delete, archive, restore, tag, archive, and preview the data in the Azure AI Foundry.
102+
After you add data to your hub-based project, you can you can delete, archive, restore, tag, archive, and preview the data in the Azure AI Foundry.
103103

104104
### Delete data
105105

articles/ai-foundry/how-to/evaluation-azure-devops.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ agent-ids: "<your-ai-agent-ids>
105105

106106
```
107107

108-
# [Hub based project](#tab/hub-project)
108+
# [Hub-based project](#tab/hub-project)
109109

110110
```yaml
111111

0 commit comments

Comments
 (0)