Skip to content

Commit 3fa43e6

Browse files
authored
Merge pull request #959 from MicrosoftDocs/foundry-updates-0005
Apply Azure.AI.Projects 2.0 GA renames and fix C# code inaccuracies
2 parents 22f3a59 + 9b984c2 commit 3fa43e6

6 files changed

Lines changed: 54 additions & 44 deletions

File tree

agent-framework/agents/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ When using Foundry, Azure OpenAI, OpenAI services, or Anthropic services, you ha
9797
| [Foundry Models](/azure/ai-foundry/concepts/foundry-models-overview) | Azure OpenAI SDK <sup>2</sup> | [Azure.AI.OpenAI](https://www.nuget.org/packages/Azure.AI.OpenAI) | https://ai-foundry-&lt;resource&gt;.services.ai.azure.com/ |
9898
| [Foundry Models](/azure/ai-foundry/concepts/foundry-models-overview) | OpenAI SDK <sup>3</sup> | [OpenAI](https://www.nuget.org/packages/OpenAI) | https://ai-foundry-&lt;resource&gt;.services.ai.azure.com/openai/v1/ |
9999
| [Foundry Models](/azure/ai-foundry/concepts/foundry-models-overview) | Azure AI Inference SDK <sup>2</sup> | [Azure.AI.Inference](https://www.nuget.org/packages/Azure.AI.Inference) | https://ai-foundry-&lt;resource&gt;.services.ai.azure.com/models |
100-
| [Foundry Agents](/azure/ai-foundry/agents/overview) | Azure AI Persistent Agents SDK | [Azure.AI.Agents.Persistent](https://www.nuget.org/packages/Azure.AI.Agents.Persistent) | https://ai-foundry-&lt;resource&gt;.services.ai.azure.com/api/projects/ai-project-&lt;project&gt; |
100+
| [Foundry Agents](/azure/ai-foundry/agents/overview) | Azure AI Projects SDK + Microsoft Agents AI Foundry | [Azure.AI.Projects](https://www.nuget.org/packages/Azure.AI.Projects) / [Microsoft.Agents.AI.Foundry](https://www.nuget.org/packages/Microsoft.Agents.AI.Foundry) | https://ai-foundry-&lt;resource&gt;.services.ai.azure.com/api/projects/ai-project-&lt;project&gt; |
101101
| [Azure OpenAI](/azure/ai-foundry/openai/overview) <sup>1</sup> | Azure OpenAI SDK <sup>2</sup> | [Azure.AI.OpenAI](https://www.nuget.org/packages/Azure.AI.OpenAI) | https://&lt;resource&gt;.openai.azure.com/ |
102102
| [Azure OpenAI](/azure/ai-foundry/openai/overview) <sup>1</sup> | OpenAI SDK | [OpenAI](https://www.nuget.org/packages/OpenAI) | https://&lt;resource&gt;.openai.azure.com/openai/v1/ |
103103
| OpenAI | OpenAI SDK | [OpenAI](https://www.nuget.org/packages/OpenAI) | No url required |
@@ -158,13 +158,13 @@ AIAgent agent = new AIProjectClient(
158158
name: "Joker");
159159
```
160160

161-
### Using the Azure AI Persistent Agents SDK
161+
### Using the Azure AI Projects SDK with Foundry Agents
162162

163-
This SDK is only supported with the Agent Service. See the table above for the correct URL to use.
163+
This SDK is used for both Responses API based agents and versioned Foundry Agents. See the table above for the correct URL to use.
164164

165165
```csharp
166-
var persistentAgentsClient = new PersistentAgentsClient(serviceUrl, new DefaultAzureCredential());
167-
AIAgent agent = await persistentAgentsClient.CreateAIAgentAsync(
166+
var aiProjectClient = new AIProjectClient(new Uri(serviceUrl), new DefaultAzureCredential());
167+
AIAgent agent = aiProjectClient.AsAIAgent(
168168
model: deploymentName,
169169
instructions: "You are good at telling jokes.",
170170
name: "Joker");

agent-framework/agents/providers/microsoft-foundry.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The Microsoft Foundry integration exposes two distinct usage patterns:
3131
| Type | Produced type | Description | Use when |
3232
|---|---|---|---|
3333
| **Responses Agent** | `ChatClientAgent` | Your app programmatically provides a model, instructions, and tools at runtime via `AIProjectClient.AsAIAgent(...)`. No server-side agent resource is created. | You own the agent definition and want a simple, flexible setup. This is the pattern used in most samples. |
34-
| **Foundry Agent** (versioned) | `FoundryAgent` | Server-managed — agent definitions are created and versioned either through the Foundry portal or programmatically via `AIProjectClient.Agents`. Pass an `AgentVersion` or `AgentRecord` or `AgentReference` to `AIProjectClient.AsAIAgent(...)`. | You need strict, versioned agent definitions managed in the Foundry portal, through service APIs |
34+
| **Foundry Agent** (versioned) | `FoundryAgent` | Server-managed — agent definitions are created and versioned either through the Foundry portal or programmatically via `AIProjectClient.AgentAdministrationClient`. Pass a `ProjectsAgentVersion` or `ProjectsAgentRecord` or `AgentReference` to `AIProjectClient.AsAIAgent(...)`. | You need strict, versioned agent definitions managed in the Foundry portal, through service APIs |
3535

3636
## Responses Agent (direct inference)
3737

@@ -60,7 +60,7 @@ This path is code-first and does not create a server-managed agent resource.
6060

6161
## Foundry Agent (versioned)
6262

63-
Use the native `AIProjectClient.Agents` APIs from the AI Projects SDK to retrieve versioned agent resources, then wrap them with `AsAIAgent`. Agents can be created and configured directly in the Foundry portal or programmatically via `AIProjectClient.Agents`.
63+
Use the native `AIProjectClient.AgentAdministrationClient` APIs from the AI Projects SDK to retrieve versioned agent resources, then wrap them with `AsAIAgent`. Agents can be created and configured directly in the Foundry portal or programmatically via `AIProjectClient.AgentAdministrationClient`.
6464

6565
```csharp
6666
using Azure.AI.Projects;
@@ -74,7 +74,7 @@ var aiProjectClient = new AIProjectClient(
7474
new DefaultAzureCredential());
7575

7676
// Retrieve an existing agent by name (uses the latest version automatically)
77-
AgentRecord jokerRecord = await aiProjectClient.Agents.GetAgentAsync("Joker");
77+
ProjectsAgentRecord jokerRecord = await aiProjectClient.AgentAdministrationClient.GetAgentAsync("Joker");
7878
FoundryAgent agent = aiProjectClient.AsAIAgent(jokerRecord);
7979

8080
Console.WriteLine(await agent.RunAsync("Tell me a joke about a pirate."));

agent-framework/agents/tools/hosted-mcp-tools.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,27 @@ mcpTool.AllowedTools.Add("microsoft_docs_search");
6666
- **serverUrl**: The URL of the hosted MCP server
6767
- **AllowedTools**: Specifies which tools from the MCP server the agent can use
6868

69-
#### 4. Persistent Agent Creation
69+
#### 4. Agent Creation
7070

71-
The agent is created server-side using the Foundry Persistent Agents SDK:
71+
The agent is created server-side using the Azure AI Projects SDK:
7272

7373
```csharp
74-
var persistentAgentsClient = new PersistentAgentsClient(endpoint, new DefaultAzureCredential());
74+
var aiProjectClient = new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential());
7575

76-
var agentMetadata = await persistentAgentsClient.Administration.CreateAgentAsync(
77-
model: model,
78-
name: AgentName,
79-
instructions: AgentInstructions,
80-
tools: [mcpTool]);
76+
var agentVersion = await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync(
77+
AgentName,
78+
new ProjectsAgentVersionCreationOptions(
79+
new DeclarativeAgentDefinition(model)
80+
{
81+
Instructions = AgentInstructions,
82+
Tools = { mcpTool }
83+
}));
8184
```
8285

8386
> [!WARNING]
8487
> `DefaultAzureCredential` is convenient for development but requires careful consideration in production. In production, consider using a specific credential (e.g., `ManagedIdentityCredential`) to avoid latency issues, unintended credential probing, and potential security risks from fallback mechanisms.
8588
86-
This creates a persistent agent that:
89+
This creates a versioned agent that:
8790
- Lives on the Foundry service
8891
- Has access to the specified MCP tools
8992
- Can maintain conversation state across multiple interactions
@@ -93,7 +96,7 @@ This creates a persistent agent that:
9396
The created agent is retrieved as an `AIAgent` instance:
9497

9598
```csharp
96-
AIAgent agent = await persistentAgentsClient.GetAIAgentAsync(agentMetadata.Value.Id);
99+
AIAgent agent = aiProjectClient.AsAIAgent(agentVersion);
97100
```
98101

99102
#### 6. Tool Resource Configuration
@@ -141,7 +144,7 @@ Console.WriteLine(response);
141144
The sample demonstrates proper resource cleanup:
142145

143146
```csharp
144-
await persistentAgentsClient.Administration.DeleteAgentAsync(agent.Id);
147+
await aiProjectClient.AgentAdministrationClient.DeleteAgentAsync(agent.Id);
145148
```
146149

147150
> [!TIP]

agent-framework/migration-guide/from-semantic-kernel/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,15 @@ Agent creation in Agent Framework is made simpler with extensions provided by al
7777

7878
```csharp
7979
AIAgent openAIAgent = chatClient.AsAIAgent(instructions: ParrotInstructions);
80-
AIAgent azureFoundryAgent = await persistentAgentsClient.CreateAIAgentAsync(instructions: ParrotInstructions);
80+
AIAgent azureFoundryAgent = aiProjectClient.AsAIAgent(model: deploymentName, instructions: ParrotInstructions);
8181
AIAgent openAIAssistantAgent = await assistantClient.CreateAIAgentAsync(instructions: ParrotInstructions);
8282
```
8383

84-
Additionally, for hosted agent providers you can also use the `GetAIAgent` method to retrieve an agent from an existing hosted agent.
84+
Additionally, for hosted agent providers you can also use the `AsAIAgent` method to retrieve an agent from an existing hosted agent record.
8585

8686
```csharp
87-
AIAgent azureFoundryAgent = await persistentAgentsClient.GetAIAgentAsync(agentId);
87+
ProjectsAgentRecord agentRecord = await aiProjectClient.AgentAdministrationClient.GetAgentAsync(agentName);
88+
AIAgent azureFoundryAgent = aiProjectClient.AsAIAgent(agentRecord);
8889
```
8990

9091
## 3. Agent Thread/Session Creation

agent-framework/workflows/agents-in-workflows.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ You'll create a workflow that:
6464
First, install the required packages for your .NET project:
6565

6666
```dotnetcli
67-
dotnet add package Azure.AI.Agents.Persistent --prerelease
67+
dotnet add package Azure.AI.Projects --prerelease
6868
dotnet add package Azure.Identity
6969
dotnet add package Microsoft.Agents.AI.Foundry --prerelease
7070
dotnet add package Microsoft.Agents.AI.Workflows --prerelease
@@ -75,21 +75,23 @@ dotnet add package Microsoft.Agents.AI.Workflows --prerelease
7575
Configure the Azure Foundry client with environment variables and authentication:
7676

7777
```csharp
78-
using Azure.AI.Agents.Persistent;
78+
using Azure.AI.Projects;
79+
using Azure.AI.Projects.Agents;
7980
using Azure.Identity;
8081
using Microsoft.Agents.AI;
82+
using Microsoft.Agents.AI.Foundry;
8183
using Microsoft.Agents.AI.Workflows;
8284
using Microsoft.Extensions.AI;
8385

8486
public static class Program
8587
{
8688
private static async Task Main()
8789
{
88-
// Set up the Azure OpenAI client
90+
// Set up the Azure AI Project client
8991
var endpoint = Environment.GetEnvironmentVariable("AZURE_AI_PROJECT_ENDPOINT")
9092
?? throw new InvalidOperationException("AZURE_AI_PROJECT_ENDPOINT is not set.");
9193
var deploymentName = Environment.GetEnvironmentVariable("AZURE_AI_MODEL_DEPLOYMENT_NAME") ?? "gpt-4o-mini";
92-
var persistentAgentsClient = new PersistentAgentsClient(endpoint, new AzureCliCredential());
94+
var aiProjectClient = new AIProjectClient(new Uri(endpoint), new AzureCliCredential());
9395
```
9496

9597
## Step 3: Create Agent Factory Method
@@ -101,20 +103,24 @@ Implement a helper method to create Azure Foundry agents with specific instructi
101103
/// Creates a translation agent for the specified target language.
102104
/// </summary>
103105
/// <param name="targetLanguage">The target language for translation</param>
104-
/// <param name="persistentAgentsClient">The PersistentAgentsClient to create the agent</param>
106+
/// <param name="aiProjectClient">The AIProjectClient to create the agent</param>
105107
/// <param name="model">The model to use for the agent</param>
106108
/// <returns>A ChatClientAgent configured for the specified language</returns>
107109
private static async Task<ChatClientAgent> GetTranslationAgentAsync(
108110
string targetLanguage,
109-
PersistentAgentsClient persistentAgentsClient,
111+
AIProjectClient aiProjectClient,
110112
string model)
111113
{
112-
var agentMetadata = await persistentAgentsClient.Administration.CreateAgentAsync(
113-
model: model,
114-
name: $"{targetLanguage} Translator",
115-
instructions: $"You are a translation assistant that translates the provided text to {targetLanguage}.");
116-
117-
return await persistentAgentsClient.GetAIAgentAsync(agentMetadata.Value.Id);
114+
string agentName = $"{targetLanguage} Translator";
115+
var version = await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync(
116+
agentName,
117+
new ProjectsAgentVersionCreationOptions(
118+
new DeclarativeAgentDefinition(model)
119+
{
120+
Instructions = $"You are a translation assistant that translates the provided text to {targetLanguage}."
121+
}));
122+
123+
return aiProjectClient.AsAIAgent(version);
118124
}
119125
}
120126
```
@@ -125,9 +131,9 @@ Create three translation agents using the helper method:
125131

126132
```csharp
127133
// Create agents
128-
AIAgent frenchAgent = await GetTranslationAgentAsync("French", persistentAgentsClient, deploymentName);
129-
AIAgent spanishAgent = await GetTranslationAgentAsync("Spanish", persistentAgentsClient, deploymentName);
130-
AIAgent englishAgent = await GetTranslationAgentAsync("English", persistentAgentsClient, deploymentName);
134+
AIAgent frenchAgent = await GetTranslationAgentAsync("French", aiProjectClient, deploymentName);
135+
AIAgent spanishAgent = await GetTranslationAgentAsync("Spanish", aiProjectClient, deploymentName);
136+
AIAgent englishAgent = await GetTranslationAgentAsync("English", aiProjectClient, deploymentName);
131137
```
132138

133139
## Step 5: Build the Workflow
@@ -169,16 +175,16 @@ Properly clean up the Azure Foundry agents after use:
169175

170176
```csharp
171177
// Cleanup the agents created for the sample.
172-
await persistentAgentsClient.Administration.DeleteAgentAsync(frenchAgent.Id);
173-
await persistentAgentsClient.Administration.DeleteAgentAsync(spanishAgent.Id);
174-
await persistentAgentsClient.Administration.DeleteAgentAsync(englishAgent.Id);
178+
await aiProjectClient.AgentAdministrationClient.DeleteAgentAsync(frenchAgent.Id);
179+
await aiProjectClient.AgentAdministrationClient.DeleteAgentAsync(spanishAgent.Id);
180+
await aiProjectClient.AgentAdministrationClient.DeleteAgentAsync(englishAgent.Id);
175181
}
176182
```
177183

178184
## How It Works
179185

180-
1. **Azure Foundry Client Setup**: Uses `PersistentAgentsClient` with Azure CLI credentials for authentication
181-
2. **Agent Creation**: Creates persistent agents on Azure Foundry with specific instructions for translation
186+
1. **Azure Foundry Client Setup**: Uses `AIProjectClient` with Azure CLI credentials for authentication
187+
2. **Agent Creation**: Creates versioned agents on Azure Foundry with specific instructions for translation
182188
3. **Sequential Processing**: French agent translates input first, then Spanish agent, then English agent
183189
4. **Turn Token Pattern**: Agents cache messages and only process when they receive a `TurnToken`
184190
5. **Streaming Updates**: `AgentResponseUpdateEvent` provides real-time token updates as agents generate responses
@@ -187,7 +193,7 @@ Properly clean up the Azure Foundry agents after use:
187193
## Key Concepts
188194

189195
- **Azure Foundry Agent Service**: Cloud-based AI agents with advanced reasoning capabilities
190-
- **PersistentAgentsClient**: Client for creating and managing agents on Azure Foundry
196+
- **AIProjectClient**: Client for creating and managing agents on Azure Foundry
191197
- **WorkflowEvent**: Output events (`type="output"`) contain agent output data (`AgentResponseUpdate` for streaming, `AgentResponse` for non-streaming)
192198
- **TurnToken**: Signal that triggers agent processing after message caching
193199
- **Sequential Workflow**: Agents connected in a pipeline where output flows from one to the next

agent-framework/workflows/declarative.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ AIProjectClient aiProjectClient = new(foundryEndpoint, new DefaultAzureCredentia
13261326
13271327
await aiProjectClient.CreateAgentAsync(
13281328
agentName: "ResearcherAgent",
1329-
agentDefinition: new PromptAgentDefinition(modelName)
1329+
agentDefinition: new DeclarativeAgentDefinition(modelName)
13301330
{
13311331
Instructions = "You are a research specialist..."
13321332
},

0 commit comments

Comments
 (0)