Skip to content

.NET: Remove Azure.AI.OpenAI dependency - #7986

Merged
Roger Barreto (rogerbarreto) merged 3 commits into
microsoft:mainfrom
rogerbarreto:aoai-migration
Sep 2, 2026
Merged

.NET: Remove Azure.AI.OpenAI dependency#7986
Roger Barreto (rogerbarreto) merged 3 commits into
microsoft:mainfrom
rogerbarreto:aoai-migration

Conversation

@rogerbarreto

Copy link
Copy Markdown
Member

Motivation & Context

The .NET tree still depends on Azure.AI.OpenAI, although the Azure SDK migration guidance recommends using the official OpenAI SDK 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

  • What are the major changes? Removes the centrally managed Azure.AI.OpenAI version and all direct package references. Azure OpenAI samples now construct OpenAIClient with BearerTokenPolicy, use the https://ai.azure.com/.default scope documented by the Azure SDK migration guide, and normalize resource roots to /openai/v1/ by inspecting the URI path. Tests that previously constructed AzureOpenAIClient now use the direct OpenAI client. Related READMEs and the Semantic Kernel migration prompt were updated. Aspire.Azure.AI.OpenAI remains because it is a separate Aspire integration package.
  • What is the impact of these changes? Consumers of these samples use one OpenAI SDK surface for OpenAI-compatible Azure endpoints. Existing resource root environment variables continue to work because the samples add the v1 path when needed. The anonymous AG-UI sample explicitly disables optional per-user session isolation for its local in-memory store, while the documentation retains the production guidance for authenticated deployments.
  • What do you want reviewers to focus on? Please focus on the Azure OpenAI endpoint normalization, the Entra audience used by 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

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings September 1, 2026 11:44
@agent-framework-automation agent-framework-automation Bot added 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 labels Sep 1, 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

Removes direct Azure.AI.OpenAI usage and migrates .NET samples and tests to the official OpenAI SDK for Azure endpoints.

Changes:

  • Replaces AzureOpenAIClient with OpenAIClient, Entra bearer authentication, and v1 endpoint normalization.
  • Removes centrally managed and project-level Azure.AI.OpenAI references.
  • 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.

Comment thread dotnet/samples/05-end-to-end/M365Agent/Program.cs
Comment thread dotnet/samples/05-end-to-end/AGUIWebChat/Server/Program.cs
Comment thread dotnet/samples/05-end-to-end/AgentWithPurview/Program.cs
Comment thread dotnet/samples/05-end-to-end/AGUIWebChat/README.md Outdated

@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.

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

Comment thread dotnet/samples/05-end-to-end/AGUIClientServer/AGUIServer/Program.cs Outdated

@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.

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.

@rogerbarreto
Roger Barreto (rogerbarreto) added this pull request to the merge queue Sep 2, 2026
Merged via the queue into microsoft:main with commit 4e0c230 Sep 2, 2026
27 checks passed
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.

.NET: Remove Azure.AI.OpenAI dependency

3 participants