Skip to content

[7.0] Enable WAM Broker support for Entra ID Auth modes (#4288)#4388

Merged
cheenamalhotra merged 6 commits into
release/7.0from
dev/cheena/7.0-wam-broker
Jun 22, 2026
Merged

[7.0] Enable WAM Broker support for Entra ID Auth modes (#4288)#4388
cheenamalhotra merged 6 commits into
release/7.0from
dev/cheena/7.0-wam-broker

Conversation

@cheenamalhotra

@cheenamalhotra cheenamalhotra commented Jun 19, 2026

Copy link
Copy Markdown
Member

Ports #4288 to release/7.0 branch.

  • Additionally, updated .NET 10 SDK to 10.0.109

Copilot AI review requested due to automatic review settings June 19, 2026 18:25
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Jun 19, 2026
@cheenamalhotra cheenamalhotra changed the title [7/0] Enable WAM Broker support for Entra ID Auth modes (#4288) [7.0] Enable WAM Broker support for Entra ID Auth modes (#4288) Jun 19, 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

Ports PR #4288 to the release/7.0 branch by enabling Windows Account Manager (WAM) broker support for Entra ID authentication in the Azure extensions package, plus related reliability hardening and a WinForms repro app for manual validation.

Changes:

  • Add WAM broker opt-in via ActiveDirectoryAuthenticationProviderOptions.UseWamBroker, new options-bag constructor, and parent-window plumbing for MSAL across platforms.
  • Harden SqlClient’s Azure-extension bootstrap/initialization and fed-auth retry behavior; add unit tests covering WAM/default-provider construction paths.
  • Add a WinForms “AzureSqlConnector” sample app for manual WAM/interactive auth validation; bump MSAL packages and update docs/snippets.

Reviewed changes

Copilot reviewed 31 out of 34 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/SqlAuthenticationProviderManagerTests.cs Adds regression + constructor-selection unit tests for Azure extension bootstrap logic.
src/Microsoft.Data.SqlClient/src/Resources/Strings.resx Adds a new localized error string for WAM-broker config requiring newer Azure extensions.
src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs Regenerates strongly-typed accessor for the new resource string.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs Adds helper to throw the new WAM-broker upgrade-required exception.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs Adds useWamBroker config parsing + new reflective construction logic for the Azure extension provider.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs Clears additional fed-auth cached state before AD-auth timeout retry.
src/Microsoft.Data.SqlClient.sln Updates solution metadata and adds the AzureSqlConnector sample project.
src/Microsoft.Data.SqlClient.Extensions/Azure/test/WamBrokerTests.cs New tests covering WAM broker defaults/opt-in behavior and parent-window callback behavior.
src/Microsoft.Data.SqlClient.Extensions/Azure/test/SqlAuthenticationProviderCollection.cs New xUnit collection to serialize tests that mutate global provider registry.
src/Microsoft.Data.SqlClient.Extensions/Azure/test/DefaultAuthProviderTests.cs Serializes this test class with the new collection.
src/Microsoft.Data.SqlClient.Extensions/Azure/test/Config.cs Minor comment update re: deprecated password auth config.
src/Microsoft.Data.SqlClient.Extensions/Azure/test/AADConnectionTest.cs Removes deprecated AAD password-flow tests; retains other Entra ID scenarios.
src/Microsoft.Data.SqlClient.Extensions/Azure/test/AADAuthenticationTests.cs Serializes this test class with the new collection.
src/Microsoft.Data.SqlClient.Extensions/Azure/src/Interop/Interop.GetConsoleWindow.cs Adds Win32 interop for console window discovery (WAM/UI parenting support).
src/Microsoft.Data.SqlClient.Extensions/Azure/src/Interop/Interop.GetAncestor.cs Adds Win32 interop for root-owner window lookup (WAM/UI parenting support).
src/Microsoft.Data.SqlClient.Extensions/Azure/src/Azure.csproj Adds MSAL Broker package reference.
src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProviderOptions.cs Introduces new options bag for configuring the AD auth provider, including WAM opt-in.
src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProvider.Windows.cs Adds Windows-specific parent-window resolution + console-window fallback.
src/Microsoft.Data.SqlClient.Extensions/Azure/src/ActiveDirectoryAuthenticationProvider.cs Implements options-bag constructor, WAM broker wiring, redirect URI changes, and forwards parent-window callback to MSAL cross-platform.
src/Microsoft.Data.SqlClient.Extensions/Azure/doc/ActiveDirectoryAuthenticationProviderOptions.xml New XML docs for the options bag type and properties.
src/Microsoft.Data.SqlClient.Extensions/Azure/doc/ActiveDirectoryAuthenticationProvider.xml Updates XML docs to describe the new options constructor + parent-window behavior.
src/Microsoft.Data.SqlClient.Extensions/Abstractions/src/SqlAuthenticationProvider.Internal.cs Minor nullability/type annotation adjustment.
doc/snippets/Microsoft.Data.SqlClient/ActiveDirectoryAuthenticationProvider.xml Updates snippet docs and adds license header.
doc/apps/AzureSqlConnector/README.md Adds documentation for the new WinForms repro/sample app.
doc/apps/AzureSqlConnector/Program.cs Adds WinForms sample app entry point + mode selector flow.
doc/apps/AzureSqlConnector/ModeSelectorForm.cs Adds a chooser dialog for UI-thread vs worker-thread open modes.
doc/apps/AzureSqlConnector/MainFormWorker.Designer.cs Adds WinForms UI for the worker-thread (sync Open) variant.
doc/apps/AzureSqlConnector/MainFormWorker.cs Implements worker-thread connection open + device code UX + AD provider registration.
doc/apps/AzureSqlConnector/MainForm.Designer.cs Adds WinForms UI for the UI-thread (async/sync selectable) variant.
doc/apps/AzureSqlConnector/MainForm.cs Implements UI-thread open patterns + device code UX + AD provider registration.
doc/apps/AzureSqlConnector/IdentityQuery.cs Shared identity query text used by both sample modes.
doc/apps/AzureSqlConnector/AzureSqlConnector.csproj New multi-targeted WinForms project for manual validation/repro.
Directory.Packages.props Bumps Microsoft.Identity.Client and adds central version for Microsoft.Identity.Client.Broker.
Files not reviewed (3)
  • doc/apps/AzureSqlConnector/MainForm.Designer.cs: Generated file
  • doc/apps/AzureSqlConnector/MainFormWorker.Designer.cs: Generated file
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Comment thread src/Microsoft.Data.SqlClient.sln
…nager

The "Analyze (csharp)" CodeQL job was failing with IL2067/IL2070 trim
analyzer errors because CreateAzureAuthenticationProvider used reflection
APIs (Activator.CreateInstance, Type.GetConstructor, Type.GetProperty) on
Type parameters that lacked [DynamicallyAccessedMembers] annotations.

Since the repo has TreatWarningsAsErrors=true, these trim warnings became
build errors and broke the CodeQL CI job.

Fix:
- Add [DynamicallyAccessedMembers(PublicParameterlessConstructor |
  PublicConstructors)] to the providerType parameter
- Add [DynamicallyAccessedMembers(PublicParameterlessConstructor |
  PublicProperties)] to the optionsType parameter
- Suppress IL2072 at the call site (assembly.GetType() returns an
  unannotated Type? which would otherwise conflict with the now-annotated
  parameters)

Co-authored-by: cheenamalhotra <13396919+cheenamalhotra@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 18:59
@cheenamalhotra cheenamalhotra removed the request for review from Copilot June 19, 2026 18:59
@cheenamalhotra cheenamalhotra added the Public API 🆕 Issues/PRs that introduce new APIs to the driver. label Jun 19, 2026
Copilot AI review requested due to automatic review settings June 19, 2026 22:36

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

Copilot reviewed 31 out of 34 changed files in this pull request and generated 3 comments.

Files not reviewed (3)
  • doc/apps/AzureSqlConnector/MainForm.Designer.cs: Generated file
  • doc/apps/AzureSqlConnector/MainFormWorker.Designer.cs: Generated file
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Comment thread src/Microsoft.Data.SqlClient/src/Resources/Strings.resx
Copilot AI review requested due to automatic review settings June 22, 2026 17:09

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

Copilot reviewed 32 out of 35 changed files in this pull request and generated 2 comments.

Files not reviewed (3)
  • doc/apps/AzureSqlConnector/MainForm.Designer.cs: Generated file
  • doc/apps/AzureSqlConnector/MainFormWorker.Designer.cs: Generated file
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Comment thread src/Microsoft.Data.SqlClient/src/Resources/Strings.resx
@cheenamalhotra cheenamalhotra marked this pull request as ready for review June 22, 2026 17:24
@cheenamalhotra cheenamalhotra requested a review from a team as a code owner June 22, 2026 17:24
@cheenamalhotra cheenamalhotra moved this from To triage to In review in SqlClient Board Jun 22, 2026
@cheenamalhotra cheenamalhotra enabled auto-merge (squash) June 22, 2026 19:16
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.26506% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.79%. Comparing base (a17f5ea) to head (76c1b41).

Files with missing lines Patch % Lines
...Data/SqlClient/SqlAuthenticationProviderManager.cs 67.10% 25 Missing ⚠️
...Data/SqlClient/Connection/SqlConnectionInternal.cs 25.00% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (a17f5ea) and HEAD (76c1b41). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (a17f5ea) HEAD (76c1b41)
CI-SqlClient 2 0
Additional details and impacted files
@@               Coverage Diff               @@
##           release/7.0    #4388      +/-   ##
===============================================
- Coverage        73.18%   65.79%   -7.39%     
===============================================
  Files              280      275       -5     
  Lines            43045    65947   +22902     
===============================================
+ Hits             31502    43390   +11888     
- Misses           11543    22557   +11014     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 65.79% <66.26%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cheenamalhotra cheenamalhotra merged commit a24c883 into release/7.0 Jun 22, 2026
301 checks passed
@cheenamalhotra cheenamalhotra deleted the dev/cheena/7.0-wam-broker branch June 22, 2026 22:50
@github-project-automation github-project-automation Bot moved this from In review to Done in SqlClient Board Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Public API 🆕 Issues/PRs that introduce new APIs to the driver.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants