.NET: Remove Azure.AI.OpenAI dependency - #7986
Conversation
There was a problem hiding this comment.
Pull request overview
Removes direct Azure.AI.OpenAI usage and migrates .NET samples and tests to the official OpenAI SDK for Azure endpoints.
Changes:
- Replaces
AzureOpenAIClientwithOpenAIClient, Entra bearer authentication, and v1 endpoint normalization. - Removes centrally managed and project-level
Azure.AI.OpenAIreferences. - Updates tests, samples, documentation, and migration guidance.
Reviewed changes
Copilot reviewed 61 out of 61 changed files in this pull request and generated 21 comments.
Show a summary per file
| File | Description |
|---|---|
dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/UserAgentPolicyTests.cs |
Migrates User-Agent tests. |
dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/Microsoft.Agents.AI.OpenAI.UnitTests.csproj |
Removes package reference. |
dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests.csproj |
Removes package reference. |
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/PolicyPipelineInvestigationTests.cs |
Migrates policy tests. |
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Microsoft.Agents.AI.Foundry.UnitTests.csproj |
Removes package reference. |
dotnet/src/Microsoft.Agents.AI.Purview/README.md |
Updates Purview usage guidance. |
dotnet/samples/05-end-to-end/M365Agent/Program.cs |
Migrates Azure client creation. |
dotnet/samples/05-end-to-end/M365Agent/M365Agent.csproj |
Removes package reference. |
dotnet/samples/05-end-to-end/AGUIWebChat/Server/Program.cs |
Migrates Azure client creation. |
dotnet/samples/05-end-to-end/AGUIWebChat/Server/AGUIWebChatServer.csproj |
Removes package reference. |
dotnet/samples/05-end-to-end/AGUIWebChat/README.md |
Updates client example. |
dotnet/samples/05-end-to-end/AGUIClientServer/README.md |
Documents anonymous isolation. |
dotnet/samples/05-end-to-end/AGUIClientServer/AGUIServer/Program.cs |
Normalizes endpoints and isolation. |
dotnet/samples/05-end-to-end/AGUIClientServer/AGUIServer/AGUIServer.csproj |
Updates encoding. |
dotnet/samples/05-end-to-end/AGUIClientServer/AGUIDojoServer/ChatClientAgentFactory.cs |
Migrates shared client creation. |
dotnet/samples/05-end-to-end/AGUIClientServer/AGUIDojoServer/AGUIDojoServer.csproj |
Removes package reference. |
dotnet/samples/05-end-to-end/AgentWithPurview/README.md |
Adds sample setup guidance. |
dotnet/samples/05-end-to-end/AgentWithPurview/Program.cs |
Migrates Azure client creation. |
dotnet/samples/05-end-to-end/AgentWithPurview/AgentWithPurview.csproj |
Removes package reference. |
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/README.md |
Updates hosted-client wording. |
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/Program.cs |
Migrates hosted workflow client. |
dotnet/samples/04-hosting/FoundryHostedAgents/responses/Hosted-Workflow-Handoff/HostedWorkflowHandoff.csproj |
Updates explicit dependencies. |
dotnet/samples/03-workflows/Concurrent/MapReduce/MapReduce.csproj |
Removes package reference. |
dotnet/samples/02-agents/ModelContextProtocol/ResponseAgent_Hosted_MCP/ResponseAgent_Hosted_MCP.csproj |
Removes package reference. |
dotnet/samples/02-agents/ModelContextProtocol/ResponseAgent_Hosted_MCP/Program.cs |
Migrates Responses clients. |
dotnet/samples/02-agents/ModelContextProtocol/Agent_MCP_Server/Program.cs |
Migrates MCP agent client. |
dotnet/samples/02-agents/ModelContextProtocol/Agent_MCP_Server/Agent_MCP_Server.csproj |
Removes package reference. |
dotnet/samples/02-agents/ModelContextProtocol/Agent_MCP_Server_Auth/README.md |
Expands authentication setup. |
dotnet/samples/02-agents/ModelContextProtocol/Agent_MCP_Server_Auth/Program.cs |
Migrates authenticated MCP client. |
dotnet/samples/02-agents/ModelContextProtocol/Agent_MCP_Server_Auth/Agent_MCP_Server_Auth.csproj |
Removes package reference. |
dotnet/samples/02-agents/ModelContextProtocol/Agent_MCP_LongRunningTask_Client/Program.cs |
Migrates long-running client. |
dotnet/samples/02-agents/ModelContextProtocol/Agent_MCP_LongRunningTask_Client/Agent_MCP_LongRunningTask_Client.csproj |
Removes package reference. |
dotnet/samples/02-agents/DevUI/DevUI_Step01_BasicUsage/Program.cs |
Migrates DevUI client. |
dotnet/samples/02-agents/DevUI/DevUI_Step01_BasicUsage/DevUI_Step01_BasicUsage.csproj |
Removes package reference. |
dotnet/samples/02-agents/DeclarativeAgents/ChatClient/Program.cs |
Migrates declarative client. |
dotnet/samples/02-agents/DeclarativeAgents/ChatClient/DeclarativeChatClientAgents.csproj |
Removes package reference. |
dotnet/samples/02-agents/AGUI/Step05_StateManagement/Server/Server.csproj |
Removes package reference. |
dotnet/samples/02-agents/AGUI/Step05_StateManagement/Server/Program.cs |
Migrates state-management client. |
dotnet/samples/02-agents/AGUI/Step04_HumanInLoop/Server/Server.csproj |
Removes package reference. |
dotnet/samples/02-agents/AGUI/Step04_HumanInLoop/Server/Program.cs |
Migrates human-in-loop client. |
dotnet/samples/02-agents/AGUI/Step03_FrontendTools/Server/Server.csproj |
Removes package reference. |
dotnet/samples/02-agents/AGUI/Step03_FrontendTools/Server/Program.cs |
Migrates frontend-tools client. |
dotnet/samples/02-agents/AGUI/Step02_BackendTools/Server/Server.csproj |
Removes package reference. |
dotnet/samples/02-agents/AGUI/Step02_BackendTools/Server/Program.cs |
Migrates backend-tools client. |
dotnet/samples/02-agents/AGUI/Step01_GettingStarted/Server/Server.csproj |
Removes package reference. |
dotnet/samples/02-agents/AGUI/Step01_GettingStarted/Server/Program.cs |
Migrates introductory client. |
dotnet/samples/02-agents/AgentSkills/Agent_Step07_SkillsAutoApproval/Program.cs |
Migrates skills client. |
dotnet/samples/02-agents/AgentSkills/Agent_Step07_SkillsAutoApproval/Agent_Step07_SkillsAutoApproval.csproj |
Removes package reference. |
dotnet/samples/02-agents/AgentProviders/foundry/Agent_Step24_CodeInterpreterFileDownload/README.md |
Removes obsolete comparison. |
dotnet/samples/02-agents/AgentProviders/foundry/Agent_Step24_CodeInterpreterFileDownload/Program.cs |
Updates container-client comment. |
dotnet/samples/02-agents/AgentProviders/azure/Agent_With_AzureOpenAIResponses/README.md |
Documents v1 endpoints. |
dotnet/samples/02-agents/AgentProviders/azure/Agent_With_AzureOpenAIResponses/Program.cs |
Migrates Responses agents. |
dotnet/samples/02-agents/AgentProviders/azure/Agent_With_AzureOpenAIResponses/Agent_With_AzureOpenAIResponses.csproj |
Removes package reference. |
dotnet/samples/02-agents/AgentProviders/azure/Agent_With_AzureOpenAIChatCompletion/README.md |
Documents v1 endpoints. |
dotnet/samples/02-agents/AgentProviders/azure/Agent_With_AzureOpenAIChatCompletion/Program.cs |
Migrates chat agent. |
dotnet/samples/02-agents/AgentProviders/azure/Agent_With_AzureOpenAIChatCompletion/Agent_With_AzureOpenAIChatCompletion.csproj |
Removes package reference. |
dotnet/samples/02-agents/A2A/A2AAgent_StreamReconnection/A2AAgent_StreamReconnection.csproj |
Removes package reference. |
dotnet/samples/02-agents/A2A/A2AAgent_PollingForTaskCompletion/A2AAgent_PollingForTaskCompletion.csproj |
Removes package reference. |
dotnet/README.md |
Updates basic agent example. |
dotnet/Directory.Packages.props |
Removes central package version. |
.github/upgrades/prompts/SemanticKernelToAgentFramework.md |
Updates migration instructions. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): ef545bedfb75
Model: gpt-5.6-sol
Overview
The review found 1 verified inline finding(s).
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 high) across 1 file. Details are attached to the affected lines below.
Affected areas: dotnet/samples/05-end-to-end/AGUIClientServer/AGUIServer/Program.cs
There was a problem hiding this comment.
MAF Automated Review — Iteration 2
Result: No findings
Scope: 1 net-new commit(s): 9a504cf728d5
Model: gpt-5.6-sol
Overview
No publishable findings were identified in the reviewed scope.
Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Motivation & Context
The .NET tree still depends on
Azure.AI.OpenAI, although the Azure SDK migration guidance recommends using the officialOpenAISDK directly for Azure OpenAI v1 endpoints. Keeping both packages adds an unnecessary dependency and leaves samples and tests with two client construction patterns.This change removes the wrapper dependency while preserving Azure authentication, Azure OpenAI resource endpoint support, and the existing Agent Framework behavior.
Description & Review Guide
Azure.AI.OpenAIversion and all direct package references. Azure OpenAI samples now constructOpenAIClientwithBearerTokenPolicy, use thehttps://ai.azure.com/.defaultscope documented by the Azure SDK migration guide, and normalize resource roots to/openai/v1/by inspecting the URI path. Tests that previously constructedAzureOpenAIClientnow use the direct OpenAI client. Related READMEs and the Semantic Kernel migration prompt were updated.Aspire.Azure.AI.OpenAIremains because it is a separate Aspire integration package.BearerTokenPolicy, the explicit dependency versions in the standalone Hosted Workflow Handoff sample, and the migrated policy and User-Agent tests.Related Issue
Fixes #7985
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.