Skip to content

.NET: .NET samples: migrate coding samples to Foundry-first AIProjectClient - #6557

Merged
Ben Thomas (alliscode) merged 10 commits into
microsoft:mainfrom
alliscode:revive/foundry-coding-alignment-v1
Jun 24, 2026
Merged

Ben Thomas (alliscode) merged 10 commits into
microsoft:mainfrom
alliscode:revive/foundry-coding-alignment-v1

Conversation

@alliscode

@alliscode Ben Thomas (alliscode) commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Continues the dotnet sample modernization sequence after structural alignment (#6485) by applying the coding migration to Foundry-first defaults.

This revives and updates the original intent from the older sample-clean work (including the #4394 thread), but rebased onto current main with current directory structure and conventions.

What changed

02-agents/Agents

  • Migrated 19 samples (Steps 01,02,03,04,05,06,08,09,10,11,12,13,14,16,17,18,19,20,21)
  • AzureOpenAIClient -> AIProjectClient.AsAIAgent(...)
  • AZURE_OPENAI_* -> FOUNDRY_PROJECT_ENDPOINT / FOUNDRY_MODEL
  • Updated .csproj references from OpenAI packages/project refs to Microsoft.Agents.AI.Foundry

02-agents other groups

  • Migrated AgentSkills (6), AgentWithMemory (4), AgentWithRAG (4), AgentOpenTelemetry (1), AgentWithCodeAct (3)
  • Updated env vars and project references similarly
  • For RAG embeddings, AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME -> FOUNDRY_EMBEDDING_MODEL

03-workflows

  • Migrated all workflow samples still using AzureOpenAIClient:
    • _StartHere (02,03,06,07)
    • Agents (CustomAgentExecutors, GroupChatToolApproval, WorkflowAsAnAgent)
    • ConditionalEdges (01,02,03)
    • Observability/WorkflowAsAnAgent
  • Updated helper flow where needed to pass AIProjectClient + model instead of an IChatClient bound to AzureOpenAIClient.

Notes

  • Provider-specific folders (for explicit provider demos) were intentionally left alone.
  • This PR preserves the intended sequencing: structure first, coding migration next.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible

Copilot AI review requested due to automatic review settings June 16, 2026 22:25
@moonbox3 Evan Mattson (moonbox3) added .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Jun 16, 2026
@github-actions github-actions Bot changed the title .NET samples: migrate coding samples to Foundry-first AIProjectClient .NET: .NET samples: migrate coding samples to Foundry-first AIProjectClient Jun 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates .NET agent/workflow samples from AzureOpenAIClient-based wiring to Foundry-first defaults using AIProjectClient and the Foundry agent helpers, aligning sample code with the framework’s current direction.

Changes:

  • Updated sample code to use AIProjectClient.AsAIAgent(...) and Foundry env vars (FOUNDRY_PROJECT_ENDPOINT, FOUNDRY_MODEL, etc.).
  • Reworked workflow helpers/factories to accept AIProjectClient + model instead of IChatClient.
  • Updated sample project references to use Microsoft.Agents.AI.Foundry (project refs and/or package refs), removing old OpenAI/AzureOpenAI-specific references.
Show a summary per file
File Description
dotnet/samples/03-workflows/Observability/WorkflowAsAnAgent/WorkflowHelper.cs Refactors workflow helper to build agents from AIProjectClient + model and adds clientFactory telemetry wiring.
dotnet/samples/03-workflows/Observability/WorkflowAsAnAgent/WorkflowAsAnAgentObservability.csproj Switches dependencies to Foundry project reference (removes old OpenAI packages).
dotnet/samples/03-workflows/Observability/WorkflowAsAnAgent/Program.cs Uses Foundry env vars and creates AIProjectClient instead of AzureOpenAIClient.
dotnet/samples/03-workflows/ConditionalEdges/03_MultiSelection/Program.cs Uses AIProjectClient + model and sets ChatOptions.ModelId for schema-based agents.
dotnet/samples/03-workflows/ConditionalEdges/03_MultiSelection/03_MultiSelection.csproj Replaces OpenAI package refs with Foundry project reference.
dotnet/samples/03-workflows/ConditionalEdges/02_SwitchCase/Program.cs Uses AIProjectClient + model and sets ChatOptions.ModelId.
dotnet/samples/03-workflows/ConditionalEdges/02_SwitchCase/02_SwitchCase.csproj Replaces OpenAI package refs with Foundry project reference.
dotnet/samples/03-workflows/ConditionalEdges/01_EdgeCondition/Program.cs Uses AIProjectClient + model and sets ChatOptions.ModelId.
dotnet/samples/03-workflows/ConditionalEdges/01_EdgeCondition/01_EdgeCondition.csproj Replaces OpenAI package refs with Foundry project reference.
dotnet/samples/03-workflows/Agents/WorkflowAsAnAgent/WorkflowFactory.cs Updates workflow factory to accept AIProjectClient + model and create agents via Foundry.
dotnet/samples/03-workflows/Agents/WorkflowAsAnAgent/WorkflowAsAnAgent.csproj Replaces OpenAI package refs with Foundry project reference.
dotnet/samples/03-workflows/Agents/WorkflowAsAnAgent/Program.cs Updates to Foundry env vars + AIProjectClient and passes model into workflow factory.
dotnet/samples/03-workflows/Agents/GroupChatToolApproval/Program.cs Migrates participant agents to aiProjectClient.AsAIAgent(model: ...).
dotnet/samples/03-workflows/Agents/GroupChatToolApproval/GroupChatToolApproval.csproj Replaces OpenAI package refs with Foundry project reference.
dotnet/samples/03-workflows/Agents/CustomAgentExecutors/Program.cs Updates custom executors to create agents via AIProjectClient.AsAIAgent(...) with ModelId.
dotnet/samples/03-workflows/Agents/CustomAgentExecutors/CustomAgentExecutors.csproj Replaces OpenAI package refs with Foundry project reference.
dotnet/samples/03-workflows/_StartHere/07_WriterCriticWorkflow/Program.cs Migrates writer/critic workflow to Foundry-first AIProjectClient + model.
dotnet/samples/03-workflows/_StartHere/07_WriterCriticWorkflow/07_WriterCriticWorkflow.csproj Adds Foundry project reference and removes old OpenAI package refs.
dotnet/samples/03-workflows/_StartHere/06_MixedWorkflowAgentsAndExecutors/Program.cs Migrates mixed workflow sample to Foundry-first AIProjectClient + model.
dotnet/samples/03-workflows/_StartHere/06_MixedWorkflowAgentsAndExecutors/06_MixedWorkflowAgentsAndExecutors.csproj Replaces OpenAI package refs with Foundry project reference.
dotnet/samples/03-workflows/_StartHere/03_AgentWorkflowPatterns/Program.cs Migrates sequential/concurrent/handoff/groupchat agents to AIProjectClient.AsAIAgent(model: ...).
dotnet/samples/03-workflows/_StartHere/03_AgentWorkflowPatterns/03_AgentWorkflowPatterns.csproj Replaces OpenAI package refs with Foundry project reference.
dotnet/samples/03-workflows/_StartHere/02_AgentsInWorkflows/Program.cs Migrates agents-in-workflows sample to Foundry-first client + model.
dotnet/samples/03-workflows/_StartHere/02_AgentsInWorkflows/02_AgentsInWorkflows.csproj Replaces OpenAI package refs with Foundry project reference.
dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step05_Neo4jGraphRAG/Program.cs Migrates Neo4j GraphRAG sample to Foundry-first client usage (but needs follow-up fixes).
dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step05_Neo4jGraphRAG/AgentWithRAG_Step05_Neo4jGraphRAG.csproj Swaps prior OpenAI deps to Microsoft.Agents.AI.Foundry package reference.
dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step03_CustomRAGDataSource/Program.cs Migrates custom RAG data source sample to AIProjectClient and sets ModelId.
dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step03_CustomRAGDataSource/AgentWithRAG_Step03_CustomRAGDataSource.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step02_CustomVectorStoreRAG/Program.cs Migrates to Foundry; updates embeddings path to GetProjectOpenAIClient().GetEmbeddingClient(...); uses FOUNDRY_EMBEDDING_MODEL.
dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step02_CustomVectorStoreRAG/AgentWithRAG_Step02_CustomVectorStoreRAG.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step01_BasicTextRAG/Program.cs Migrates to Foundry; updates embeddings to GetProjectOpenAIClient().GetEmbeddingClient(...); uses FOUNDRY_EMBEDDING_MODEL.
dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step01_BasicTextRAG/AgentWithRAG_Step01_BasicTextRAG.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step05_BoundedChatHistory/Program.cs Migrates to Foundry; uses project OpenAI client for embeddings and sets ChatOptions.ModelId.
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step05_BoundedChatHistory/AgentWithMemory_Step05_BoundedChatHistory.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step03_MemoryUsingValkey/Program.cs Migrates to Foundry; removes OpenAI.Chat usage; sets ChatOptions.ModelId.
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step03_MemoryUsingValkey/AgentWithMemory_Step03_MemoryUsingValkey.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step02_MemoryUsingMem0/Program.cs Migrates to Foundry; creates AIProjectClient and sets ChatOptions.ModelId.
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step02_MemoryUsingMem0/AgentWithMemory_Step02_MemoryUsingMem0.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step01_ChatHistoryMemory/Program.cs Migrates to Foundry; uses project OpenAI client for embeddings and sets ChatOptions.ModelId.
dotnet/samples/02-agents/AgentWithMemory/AgentWithMemory_Step01_ChatHistoryMemory/AgentWithMemory_Step01_ChatHistoryMemory.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentWithCodeAct/AgentWithCodeAct_Step03_ManualWiring/Program.cs Migrates to Foundry-first and passes model: explicitly.
dotnet/samples/02-agents/AgentWithCodeAct/AgentWithCodeAct_Step03_ManualWiring/AgentWithCodeAct_Step03_ManualWiring.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentWithCodeAct/AgentWithCodeAct_Step02_ToolEnabled/Program.cs Migrates to Foundry; sets ChatOptions.ModelId; removes OpenAI.Chat dependency.
dotnet/samples/02-agents/AgentWithCodeAct/AgentWithCodeAct_Step02_ToolEnabled/AgentWithCodeAct_Step02_ToolEnabled.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentWithCodeAct/AgentWithCodeAct_Step01_Interpreter/Program.cs Migrates to Foundry; sets ChatOptions.ModelId; removes OpenAI.Chat dependency.
dotnet/samples/02-agents/AgentWithCodeAct/AgentWithCodeAct_Step01_Interpreter/AgentWithCodeAct_Step01_Interpreter.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentSkills/Agent_Step06_McpBasedSkills/Program.cs Migrates MCP skills sample to Foundry-first and sets ChatOptions.ModelId.
dotnet/samples/02-agents/AgentSkills/Agent_Step06_McpBasedSkills/Agent_Step06_McpBasedSkills.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentSkills/Agent_Step05_SkillsWithDI/Program.cs Migrates DI-based skills sample to Foundry-first and sets ChatOptions.ModelId.
dotnet/samples/02-agents/AgentSkills/Agent_Step05_SkillsWithDI/Agent_Step05_SkillsWithDI.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentSkills/Agent_Step04_MixedSkills/Program.cs Migrates mixed skills sample to Foundry-first and sets ChatOptions.ModelId.
dotnet/samples/02-agents/AgentSkills/Agent_Step04_MixedSkills/Agent_Step04_MixedSkills.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentSkills/Agent_Step03_ClassBasedSkills/Program.cs Migrates class-based skills sample to Foundry-first and sets ChatOptions.ModelId.
dotnet/samples/02-agents/AgentSkills/Agent_Step03_ClassBasedSkills/Agent_Step03_ClassBasedSkills.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentSkills/Agent_Step02_CodeDefinedSkills/Program.cs Migrates code-defined skills sample to Foundry-first and sets ChatOptions.ModelId.
dotnet/samples/02-agents/AgentSkills/Agent_Step02_CodeDefinedSkills/Agent_Step02_CodeDefinedSkills.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentSkills/Agent_Step01_FileBasedSkills/Program.cs Migrates file-based skills sample to Foundry-first and sets ChatOptions.ModelId.
dotnet/samples/02-agents/AgentSkills/Agent_Step01_FileBasedSkills/Agent_Step01_FileBasedSkills.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step21_ShellWithEnvironment/Program.cs Migrates shell tool sample to AIProjectClient.AsAIAgent(...) and sets ModelId.
dotnet/samples/02-agents/Agents/Agent_Step21_ShellWithEnvironment/Agent_Step21_ShellWithEnvironment.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step20_DynamicFunctionTools/Program.cs Migrates dynamic tools sample to Foundry agent + clientFactory middleware wiring.
dotnet/samples/02-agents/Agents/Agent_Step20_DynamicFunctionTools/Agent_Step20_DynamicFunctionTools.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step19_InFunctionLoopCheckpointing/Program.cs Migrates checkpointing sample to Foundry Responses client wiring for model; updates env vars.
dotnet/samples/02-agents/Agents/Agent_Step19_InFunctionLoopCheckpointing/Agent_Step19_InFunctionLoopCheckpointing.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step18_CompactionPipeline/Program.cs Migrates compaction pipeline sample to Foundry-first client setup and responses chat clients.
dotnet/samples/02-agents/Agents/Agent_Step18_CompactionPipeline/Agent_Step18_CompactionPipeline.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step17_AdditionalAIContext/Program.cs Migrates custom AIContextProviders sample to Foundry-first and sets ModelId.
dotnet/samples/02-agents/Agents/Agent_Step17_AdditionalAIContext/Agent_Step17_AdditionalAIContext.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step16_Declarative/Program.cs Migrates declarative agent sample to Foundry-first; uses responses chat client from project.
dotnet/samples/02-agents/Agents/Agent_Step16_Declarative/Agent_Step16_Declarative.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step14_BackgroundResponses/Program.cs Migrates background responses sample to Foundry-first agent construction.
dotnet/samples/02-agents/Agents/Agent_Step14_BackgroundResponses/Agent_Step14_BackgroundResponses.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step13_ChatReduction/Program.cs Migrates chat reduction sample to Foundry-first and sets ModelId.
dotnet/samples/02-agents/Agents/Agent_Step13_ChatReduction/Agent_Step13_ChatReduction.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step12_Plugins/Program.cs Migrates plugin/DI tools sample to Foundry-first agent creation.
dotnet/samples/02-agents/Agents/Agent_Step12_Plugins/Agent_Step12_Plugins.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step11_Middleware/Program.cs Migrates middleware sample to Foundry-first with clientFactory pipeline customization.
dotnet/samples/02-agents/Agents/Agent_Step11_Middleware/Agent_Step11_Middleware.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step10_BackgroundResponsesWithToolsAndPersistence/Program.cs Migrates background responses + persistence sample to Foundry-first agent construction.
dotnet/samples/02-agents/Agents/Agent_Step10_BackgroundResponsesWithToolsAndPersistence/Agent_Step10_BackgroundResponsesWithToolsAndPersistence.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step09_AsFunctionTool/Program.cs Migrates “agent as tool” sample to Foundry-first; builds both agents from project client.
dotnet/samples/02-agents/Agents/Agent_Step09_AsFunctionTool/Agent_Step09_AsFunctionTool.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step08_UsingImages/Program.cs Migrates vision sample to Foundry-first and passes model: explicitly.
dotnet/samples/02-agents/Agents/Agent_Step08_UsingImages/Agent_Step08_UsingImages.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step06_DependencyInjection/Program.cs Migrates DI sample to Foundry-first by creating agent via AIProjectClient.AsAIAgent(...).
dotnet/samples/02-agents/Agents/Agent_Step06_DependencyInjection/Agent_Step06_DependencyInjection.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step05_Observability/Program.cs Migrates observability sample to Foundry-first and uses agent-level OpenTelemetry builder.
dotnet/samples/02-agents/Agents/Agent_Step05_Observability/Agent_Step05_Observability.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step04_3rdPartyChatHistoryStorage/Program.cs Migrates custom chat history provider sample to Foundry-first and sets ModelId.
dotnet/samples/02-agents/Agents/Agent_Step04_3rdPartyChatHistoryStorage/Agent_Step04_3rdPartyChatHistoryStorage.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step03_PersistedConversations/Program.cs Migrates persisted conversations sample to Foundry-first AIProjectClient.AsAIAgent(model: ...).
dotnet/samples/02-agents/Agents/Agent_Step03_PersistedConversations/Agent_Step03_PersistedConversations.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step02_StructuredOutput/Program.cs Migrates structured output sample to Foundry-first and updates structured output wiring.
dotnet/samples/02-agents/Agents/Agent_Step02_StructuredOutput/Agent_Step02_StructuredOutput.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/Agents/Agent_Step01_UsingFunctionToolsWithApprovals/Program.cs Migrates approvals/tools sample to Foundry-first agent creation.
dotnet/samples/02-agents/Agents/Agent_Step01_UsingFunctionToolsWithApprovals/Agent_Step01_UsingFunctionToolsWithApprovals.csproj Replaces OpenAI deps with Foundry project reference.
dotnet/samples/02-agents/AgentOpenTelemetry/Program.cs Migrates end-to-end OTel sample to Foundry-first with clientFactory + agent-level OTel.
dotnet/samples/02-agents/AgentOpenTelemetry/AgentOpenTelemetry.csproj Replaces OpenAI deps with Foundry project reference and trims unused packages.

Copilot's findings

Comments suppressed due to low confidence (1)

dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step05_Neo4jGraphRAG/Program.cs:62

  • This sample now calls AIProjectClient.AsIChatClient(deploymentName), but there is no AsIChatClient extension for AIProjectClient. Also, ChatClientAgentOptions.ChatOptions is missing ModelId, so AIProjectClient.AsAIAgent(options) will throw/ fail to compile. Create the agent directly from AIProjectClient and set ChatOptions.ModelId.
  • Files reviewed: 98/98 changed files
  • Comments generated: 9

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 5 | Confidence: 91%

✓ Correctness

No actionable issues found in this dimension.

✓ Security Reliability

No actionable issues found in this dimension.

✓ Test Coverage

No actionable issues found in this dimension.

✓ Failure Modes

No actionable issues found in this dimension.

✗ Design Approach

I found one blocking issue in the Foundry migration for these samples: the Neo4j GraphRAG sample switched to a chat-client construction pattern that is inconsistent with the repo’s established Foundry integration path and should be aligned before merge. I found one design issue in the migrated samples: a couple of programs now bypass the repo's Foundry wrapper path and construct raw Responses chat clients directly, which diverges from the centralized Foundry-first pattern the codebase added for uniform telemetry and request handling.

Flagged Issues

  • dotnet/samples/03-workflows/_StartHere/06_MixedWorkflowAgentsAndExecutors/06_MixedWorkflowAgentsAndExecutors.csproj:11-15 and dotnet/samples/03-workflows/_StartHere/07_WriterCriticWorkflow/07_WriterCriticWorkflow.csproj:12-20 drop the explicit Azure.Identity reference even though their Program.cs files instantiate DefaultAzureCredential (06../Program.cs:46, 07.../Program.cs:53).

Suggestions

  • Update dotnet/samples/03-workflows/_StartHere/07_WriterCriticWorkflow/Program.cs:39 to describe Foundry prerequisites, since the sample now reads FOUNDRY_PROJECT_ENDPOINT / FOUNDRY_MODEL at lines 51-52.

Automated review by alliscode's agents

@github-actions

Copy link
Copy Markdown
Contributor

Flagged issue

dotnet/samples/03-workflows/_StartHere/06_MixedWorkflowAgentsAndExecutors/06_MixedWorkflowAgentsAndExecutors.csproj:11-15 and dotnet/samples/03-workflows/_StartHere/07_WriterCriticWorkflow/07_WriterCriticWorkflow.csproj:12-20 drop the explicit Azure.Identity reference even though their Program.cs files instantiate DefaultAzureCredential (06../Program.cs:46, 07.../Program.cs:53).


Source: automated DevFlow PR review

@rogerbarreto

Copy link
Copy Markdown
Member

Docs not updated for the Foundry migration

This PR migrates the sample code to Foundry but leaves the sample READMEs on the old Azure OpenAI setup, so the docs now contradict the code. Consolidating the per file notes here (re posting the summary table that was dropped from my review).

Variable rename needed across the affected READMEs:

Old (Azure OpenAI) New (Foundry)
AZURE_OPENAI_ENDPOINT (https://<res>.openai.azure.com/) FOUNDRY_PROJECT_ENDPOINT (https://<svc>.services.ai.azure.com/api/projects/<project>)
AZURE_OPENAI_DEPLOYMENT_NAME FOUNDRY_MODEL
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME FOUNDRY_EMBEDDING_MODEL

Legend: endpoint = AZURE_OPENAI_ENDPOINT to FOUNDRY_PROJECT_ENDPOINT, model = AZURE_OPENAI_DEPLOYMENT_NAME to FOUNDRY_MODEL, embedding = AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME to FOUNDRY_EMBEDDING_MODEL.

READMEs needing only the variable rename

# Sample README (under dotnet/samples/) Vars
1 02-agents/Agents/Agent_Step02_StructuredOutput/README.md endpoint, model
2 02-agents/Agents/Agent_Step10_BackgroundResponsesWithToolsAndPersistence/README.md endpoint, model
3 02-agents/Agents/Agent_Step14_BackgroundResponses/README.md endpoint, model
4 02-agents/Agents/Agent_Step18_CompactionPipeline/README.md endpoint, model
5 02-agents/Agents/Agent_Step19_InFunctionLoopCheckpointing/README.md endpoint, model
6 02-agents/Agents/Agent_Step20_DynamicFunctionTools/README.md endpoint, model
7 02-agents/AgentSkills/Agent_Step01_FileBasedSkills/README.md endpoint, model
8 02-agents/AgentSkills/Agent_Step02_CodeDefinedSkills/README.md endpoint, model
9 02-agents/AgentSkills/Agent_Step03_ClassBasedSkills/README.md endpoint, model
10 02-agents/AgentSkills/Agent_Step04_MixedSkills/README.md endpoint, model
11 02-agents/AgentSkills/Agent_Step05_SkillsWithDI/README.md endpoint, model
12 02-agents/AgentSkills/Agent_Step06_McpBasedSkills/README.md endpoint, model
13 02-agents/AgentWithCodeAct/AgentWithCodeAct_Step01_Interpreter/README.md endpoint, model
14 02-agents/AgentWithCodeAct/AgentWithCodeAct_Step02_ToolEnabled/README.md endpoint, model
15 02-agents/AgentWithCodeAct/AgentWithCodeAct_Step03_ManualWiring/README.md endpoint, model
16 02-agents/AgentWithMemory/AgentWithMemory_Step03_MemoryUsingValkey/README.md endpoint, model
17 02-agents/AgentWithMemory/AgentWithMemory_Step05_BoundedChatHistory/README.md endpoint, model, embedding
18 02-agents/AgentWithRAG/AgentWithRAG_Step02_CustomVectorStoreRAG/README.md endpoint, model, embedding
19 02-agents/AgentWithRAG/AgentWithRAG_Step05_Neo4jGraphRAG/README.md endpoint, model
20 03-workflows/Agents/GroupChatToolApproval/README.md endpoint, model
21 03-workflows/_StartHere/06_MixedWorkflowAgentsAndExecutors/README.md endpoint, model

READMEs with extra prose or structural references

These need the variable rename plus wording fixes, flagged in the dedicated inline review comments:

  • 02-agents/AgentOpenTelemetry/README.md
  • 02-agents/Agents/Agent_Step08_UsingImages/README.md
  • 02-agents/Agents/Agent_Step11_Middleware/README.md
  • 02-agents/Agents/README.md (group doc)

Provider docs under AgentProviders/azure and AgentProviders/foundry are intentionally left as is.

Ben Thomas (alliscode) and others added 5 commits June 19, 2026 10:00
Replace AzureOpenAIClient with AIProjectClient as the AI provider in all
02-agents/Agents samples, aligning with the Foundry-first approach.

Changes:
- 19 Program.cs files migrated to use AIProjectClient.AsAIAgent()
- 19 .csproj files updated (Azure.AI.OpenAI -> Microsoft.Agents.AI.Foundry)
- Environment variables: AZURE_OPENAI_* -> FOUNDRY_PROJECT_ENDPOINT/FOUNDRY_MODEL
- Updated description comments to reflect Foundry backend
- Provider-specific samples in AgentsWithFoundry/ intentionally unchanged

Co-authored-by: Copilot <[email protected]>
…enTelemetry to AIProjectClient

Replace AzureOpenAIClient with AIProjectClient as the AI provider.
Environment variables: AZURE_OPENAI_* -> FOUNDRY_PROJECT_ENDPOINT/FOUNDRY_MODEL.

Co-authored-by: Copilot <[email protected]>
Replace AzureOpenAIClient with AIProjectClient as the AI provider in
all 03-workflows samples that use an AI model.
Environment variables: AZURE_OPENAI_* -> FOUNDRY_PROJECT_ENDPOINT/FOUNDRY_MODEL.

Co-authored-by: Copilot <[email protected]>
- Add explicit Azure.Identity package references to migrated sample projects
  that use DefaultAzureCredential
- Fix AgentWithRAG_Step05_Neo4jGraphRAG to use AIProjectClient.AsAIAgent()
  with ChatOptions.ModelId instead of AIProjectClient.AsIChatClient()
- Keep migrated samples on AIProjectClient pattern (no FoundryAgent/AzureOpenAIClient)

Co-authored-by: Copilot <[email protected]>
@alliscode
Ben Thomas (alliscode) force-pushed the revive/foundry-coding-alignment-v1 branch from 7b44536 to 25aa168 Compare June 19, 2026 17:01
@moonbox3 Evan Mattson (moonbox3) added the documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs label Jun 19, 2026
@alliscode
Ben Thomas (alliscode) added this pull request to the merge queue Jun 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 22, 2026
@alliscode
Ben Thomas (alliscode) added this pull request to the merge queue Jun 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 23, 2026
@alliscode
Ben Thomas (alliscode) added this pull request to the merge queue Jun 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 23, 2026
@alliscode
Ben Thomas (alliscode) added this pull request to the merge queue Jun 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 23, 2026
@alliscode
Ben Thomas (alliscode) added this pull request to the merge queue Jun 23, 2026
@alliscode
Ben Thomas (alliscode) removed this pull request from the merge queue due to a manual request Jun 23, 2026
@alliscode
Ben Thomas (alliscode) added this pull request to the merge queue Jun 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 23, 2026
@alliscode
Ben Thomas (alliscode) added this pull request to the merge queue Jun 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 24, 2026
@alliscode
Ben Thomas (alliscode) merged commit 336a19f into microsoft:main Jun 24, 2026
28 checks passed
Eduard van Valkenburg (eavanvalkenburg) pushed a commit to eavanvalkenburg/agent-framework that referenced this pull request Oct 26, 2026
…crosoft#9600)

microsoft#6557 moved these samples' code to AIProjectClient and FOUNDRY_PROJECT_ENDPOINT /
FOUNDRY_MODEL (and FOUNDRY_EMBEDDING_MODEL), but their READMEs still told readers
to set AZURE_OPENAI_ENDPOINT / AZURE_OPENAI_DEPLOYMENT_NAME, so following the
README fails with "FOUNDRY_PROJECT_ENDPOINT is not set."

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants