Use openai package instead of legacy azure openai package (#12375)#12376
Use openai package instead of legacy azure openai package (#12375)#12376yasmoradi wants to merge 5 commits into
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR removes the legacy ChangesAzure OpenAI Removal Across Codebase
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR migrates the Platform server, BlazorUI Demo server, Boilerplate templates, and the ResxTranslator tool away from the legacy Microsoft.Extensions.AI.AzureAIInference (Azure Azure.AI.Inference.* clients) to the Microsoft.Extensions.AI.OpenAI integration, removing the AzureAIInference package references and associated AzureOpenAI configuration paths.
Changes:
- Removed
Microsoft.Extensions.AI.AzureAIInferencepackage references and deleted AzureOpenAI chat/embedding wiring in service registration. - Simplified configuration models and appsettings templates by removing
AzureOpenAIsections (mostly) and expanding OpenAI endpoint samples. - Updated ResxTranslator docs/config guidance to focus on OpenAI configuration (but requires fixes; see comments).
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Services.cs | Removes AzureOpenAI chat client wiring; registers OpenAI chat client only. |
| src/Websites/Platform/src/Bit.Websites.Platform.Server/Bit.Websites.Platform.Server.csproj | Drops AzureAIInference package reference. |
| src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json | Changes default chat temperature; AzureOpenAI section still present. |
| src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/appsettings.json | Removes AzureOpenAI block from template config. |
| src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/ServerApiSettings.cs | Removes AzureOpenAIOptions from settings model. |
| src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs | Removes AzureOpenAI chat + embedding registration paths. |
| src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Boilerplate.Server.Api.csproj | Drops AzureAIInference package reference (conditional). |
| src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/appsettings.json | Removes AzureOpenAI config and adds OpenAI endpoint sample keys. |
| src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props | Removes centrally-managed AzureAIInference package version. |
| src/Templates/Boilerplate/Bit.Boilerplate/Bit.ResxTranslator.json | Removes AzureOpenAI provider config; adds OpenAI endpoint samples and key comment. |
| src/ResxTranslator/README.md | Updates env var guidance; adds endpoint samples (needs corrections). |
| src/ResxTranslator/Bit.ResxTranslator/Program.cs | Removes AzureOpenAI branch (but leaves Azure-related wording/usings; needs fixes). |
| src/ResxTranslator/Bit.ResxTranslator/Models/ResxTranslatorSettings.cs | Removes AzureOpenAI settings property. |
| src/ResxTranslator/Bit.ResxTranslator/Bit.ResxTranslator.csproj | Drops AzureAIInference package reference. |
| src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Services.cs | Removes AzureOpenAI chat client wiring; registers OpenAI chat client only. |
| src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Bit.BlazorUI.Demo.Server.csproj | Drops AzureAIInference package reference. |
| src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/appsettings.json | Removes AzureOpenAI config and changes default chat temperature. |
| src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/AppSettings.cs | Removes AzureOpenAI options model from demo server settings. |
Comments suppressed due to low confidence (2)
src/ResxTranslator/Bit.ResxTranslator/Program.cs:68
- The Azure OpenAI branch was removed, but the fallback exception message still says "No OpenAI or Azure OpenAI API key provided." and the file still imports Azure-specific namespaces (Azure.AI.Inference / Azure.Core.Pipeline). With Microsoft.Extensions.AI.AzureAIInference removed from the project, these Azure usings will likely fail compilation and the message is now misleading. Update the error text to only mention OpenAI, and remove any remaining Azure-specific usings/references in this file.
else
{
throw new InvalidOperationException("No OpenAI or Azure OpenAI API key provided.");
}
src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Services.cs:55
- AzureOpenAI-based chat client registration was removed, but this project still has AzureOpenAI settings in AppSettings/appsettings.json. As a result, deployments that only set AppSettings:AzureOpenAI:ChatApiKey (and not OpenAI:ChatApiKey) will no longer register an IChatClient and the chatbot features will silently stop working. Either remove AzureOpenAI from the configuration surface, or keep backward compatibility by mapping AzureOpenAI settings to the OpenAI client configuration.
if (string.IsNullOrEmpty(appSettings?.OpenAI?.ChatApiKey) is false)
{
// https://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.AI.OpenAI#microsoftextensionsaiopenai
services.AddChatClient(sp => new OpenAI.Chat.ChatClient(model: appSettings.OpenAI.ChatModel, credential: new(appSettings.OpenAI.ChatApiKey), options: new()
{
Endpoint = appSettings.OpenAI.ChatEndpoint,
Transport = new HttpClientPipelineTransport(sp.GetRequiredService<IHttpClientFactory>().CreateClient("AI"))
}).AsIChatClient())
.UseLogging()
.UseFunctionInvocation()
.UseDistributedCache();
}
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/ResxTranslator/README.md (1)
3-3:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove stale Azure OpenAI references from README text.
These lines still state OpenAI or Azure OpenAI, which conflicts with the OpenAI-only runtime/config changes in this PR stack and can mislead setup decisions.
Also applies to: 9-9, 26-26
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/ResxTranslator/README.md` at line 3, The README's description for Bit.ResxTranslator still mentions "OpenAI or Azure OpenAI" which is stale; update all occurrences (e.g., the initial sentence containing "OpenAI or Azure OpenAI" and the other lines flagged) to reference only "OpenAI" (remove "or Azure OpenAI" and any Azure-specific phrasing), and scan the README for any other Azure OpenAI mentions (lines similar to the phrase) and replace them with OpenAI-only wording to reflect the runtime/config changes.
🧹 Nitpick comments (1)
src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json (1)
18-29: ⚡ Quick winRemove stale
AzureOpenAIconfiguration from Platform settings.The runtime registration path is OpenAI-only, so keeping
AppSettings.AzureOpenAIhere is obsolete and can cause operator confusion about which key/endpoint is active.Proposed cleanup
"ChatOptions": { "Temperature": 1 }, - "AzureOpenAI": { - "ChatModel": "gpt-4.1-mini", - "ChatApiKey": null, - "ChatEndpoint": null - }, "OpenAI": { "ChatModel": "gpt-4.1-mini", "ChatApiKey": null, "ChatEndpoint": null }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json` around lines 18 - 29, Remove the obsolete AzureOpenAI configuration block from appsettings.json to avoid operator confusion: delete the "AzureOpenAI" object (the keys "ChatModel", "ChatApiKey", "ChatEndpoint") so only the "OpenAI" settings remain; verify consumer code expects AppSettings.OpenAI (not AppSettings.AzureOpenAI) and update any references in configuration binding or docs to point to OpenAI-only settings.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/ResxTranslator/README.md`:
- Around line 46-47: The JSON example in README has a missing comma after the
"ApiKey" entry which makes the sample invalid; update the configuration snippet
so there is a comma separating "ApiKey": null and "ApiKey__Comment": "...", i.e.
insert the missing comma after the "ApiKey" property so the "ApiKey" and
"ApiKey__Comment" entries form valid JSON.
- Line 52: Fix the typo in the Security Note by replacing the incorrect config
filename "Bit.RexsTranslator.json" with the correct "Bit.ResxTranslator.json" in
the README.md Security Note so the environment-variable guidance references the
right config file.
---
Outside diff comments:
In `@src/ResxTranslator/README.md`:
- Line 3: The README's description for Bit.ResxTranslator still mentions "OpenAI
or Azure OpenAI" which is stale; update all occurrences (e.g., the initial
sentence containing "OpenAI or Azure OpenAI" and the other lines flagged) to
reference only "OpenAI" (remove "or Azure OpenAI" and any Azure-specific
phrasing), and scan the README for any other Azure OpenAI mentions (lines
similar to the phrase) and replace them with OpenAI-only wording to reflect the
runtime/config changes.
---
Nitpick comments:
In `@src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json`:
- Around line 18-29: Remove the obsolete AzureOpenAI configuration block from
appsettings.json to avoid operator confusion: delete the "AzureOpenAI" object
(the keys "ChatModel", "ChatApiKey", "ChatEndpoint") so only the "OpenAI"
settings remain; verify consumer code expects AppSettings.OpenAI (not
AppSettings.AzureOpenAI) and update any references in configuration binding or
docs to point to OpenAI-only settings.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: cdcfa09d-15fa-4b33-b207-54fcff3ae4bb
📒 Files selected for processing (18)
src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/AppSettings.cssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Bit.BlazorUI.Demo.Server.csprojsrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Services.cssrc/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/appsettings.jsonsrc/ResxTranslator/Bit.ResxTranslator/Bit.ResxTranslator.csprojsrc/ResxTranslator/Bit.ResxTranslator/Models/ResxTranslatorSettings.cssrc/ResxTranslator/Bit.ResxTranslator/Program.cssrc/ResxTranslator/README.mdsrc/Templates/Boilerplate/Bit.Boilerplate/Bit.ResxTranslator.jsonsrc/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.propssrc/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Boilerplate.Server.Api.csprojsrc/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cssrc/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/ServerApiSettings.cssrc/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/appsettings.jsonsrc/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/appsettings.jsonsrc/Websites/Platform/src/Bit.Websites.Platform.Server/Bit.Websites.Platform.Server.csprojsrc/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Services.cssrc/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json
💤 Files with no reviewable changes (11)
- src/Websites/Platform/src/Bit.Websites.Platform.Server/Bit.Websites.Platform.Server.csproj
- src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/appsettings.json
- src/ResxTranslator/Bit.ResxTranslator/Models/ResxTranslatorSettings.cs
- src/ResxTranslator/Bit.ResxTranslator/Program.cs
- src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/ServerApiSettings.cs
- src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Boilerplate.Server.Api.csproj
- src/ResxTranslator/Bit.ResxTranslator/Bit.ResxTranslator.csproj
- src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props
- src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Program.Services.cs
- src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/AppSettings.cs
- src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Bit.BlazorUI.Demo.Server.csproj
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Yas Moradi <yas_moradi@outlook.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (3)
src/Websites/Platform/src/Bit.Websites.Platform.Server/appsettings.json:24
AzureOpenAIis still present in the default configuration even though the code path for Azure OpenAI has been removed in this PR. This is likely to confuse users (it suggests AzureOpenAI is still supported). Consider removing theAzureOpenAIsection (and any related settings/docs) or clearly marking it as unsupported/deprecated so configuration matches runtime behavior.
"Temperature": 1
},
"AzureOpenAI": {
"ChatModel": "gpt-4.1-mini",
"ChatApiKey": null,
"ChatEndpoint": null
},
src/ResxTranslator/Bit.ResxTranslator/Program.cs:68
- After removing the Azure OpenAI code path, this exception message is now inaccurate. It should mention only the supported configuration (OpenAI) so users know which key/section is required.
else
{
throw new InvalidOperationException("No OpenAI or Azure OpenAI API key provided.");
}
src/ResxTranslator/Bit.ResxTranslator/Bit.ResxTranslator.csproj:23
- This project no longer references
Microsoft.Extensions.AI.AzureAIInference, butProgram.csstill hasusing Azure.AI.Inference;/using Azure.Core.Pipeline;directives. Without explicit package references those usings will fail to compile. Remove the leftover Azure usings (or add back the required Azure packages if Azure support is still intended).
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.AI" Version="10.6.0" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.6.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.8" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.8" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.8" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="10.0.8" />
</ItemGroup>
closes #12375
Summary by CodeRabbit
Improvements
Documentation