You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add authentication diagnostics to the Azure extension through SqlClient's EventSource. No callbacks, no PII.
Add the AuthenticationTrace keyword (0x2000) to Microsoft.Data.SqlClient.EventSource. Auth events (IDs 22–27) use only this keyword, so they can be collected on their own or together with ordinary Trace (0x2002).
Forward MSAL logs (PII disabled), an allowlisted subset of Azure.Identity events, and SqlClient token start/success/failure events. Each event has message, source (SqlClient, MSAL, Azure-Identity) and connectionId.
Azure.Identity events are forwarded only during extension-owned token requests, so the app's own Azure SDK traffic is not captured.
Add dotnet-trace and in-process EventListener samples; document usage, privacy and known limitations in the package README.
Suggested release note: Azure extension authentication diagnostics (MSAL, Azure.Identity and token acquisition) can be collected with the new AuthenticationTrace EventSource keyword.
ActiveDirectoryManagedIdentity (no MI on host): expected failure; 41 events including MSAL MI flow, the Azure.Identity failure and SqlClient Token acquisition failed., one connection ID.
ActiveDirectoryInteractive (earlier run): connected; MSAL and SqlClient events correlated by connection ID.
Not run: Windows/.NET Framework runtime, WAM broker, and performance measurements.
Guidelines
Please review the contribution guidelines before submitting a pull request:
Adds an authentication logging callback and MSAL PII opt-in to
ActiveDirectoryAuthenticationProviderOptions, with EventSource tracing
for MSAL and Azure Identity diagnostics.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 9881423d-614d-429e-ba7d-612fbfbcb52e
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Privacy-sensitive event forwarding and shared token-cache synchronization warrant human review, particularly for unexecuted Windows, .NET Framework, and WAM runtime paths.
No open issues 🎉
What changed in this PR
Adds Azure extension authentication diagnostics through independent EventSource tracing and optional application callbacks, addressing issue #1846.
Changes:
Introduces SqlClient-owned logging contracts and callback-only MSAL PII opt-in.
Adds scoped SDK logging and coordinated token caches across compatible provider replacements.
Adds regression tests, API documentation, and a usage sample.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Privacy-sensitive forwarding and shared token-cache synchronization need human review, particularly with Windows, .NET Framework, and WAM runtime paths unverified.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Privacy-sensitive forwarding and token-cache synchronization need human review, particularly with Windows, .NET Framework, and WAM runtime paths unverified.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.13%. Comparing base (7b1184b) to head (0847eeb). ⚠️ Report is 5 commits behind head on main.
The reason will be displayed to describe this comment to others. Learn more.
This is a huge change and I'm really concerned we're building something from scratch that we either already have or can leverage an external package to provide. Let's consider this a bit more in-depth before we rush to get it merged
Add braces, use auto-property, drop wrapper property, use named
arguments and ternaries, and add Arrange/Act/Assert headers.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 9881423d-614d-429e-ba7d-612fbfbcb52e
[P2] Coordinate the initial subscription refresh with collector commands. The constructor calls ApplySubscriptions() outside EventSource's subscription lock. For an existing Azure-Identity source, it can set state.Level to Informational here and pause before EnableEvents. A concurrent collector command can then set and apply Verbose, after which the constructor applies its stale Informational subscription. The version check retries, but ApplySource skips the repair because the cached level is already Verbose. Requested Verbose SDK events are then dropped until a later subscription update repairs the mismatch. Coordinate initialization with command-driven updates, or reconcile stale subscription calls without trusting the cached level. Preserve reentrant command handling and add a concurrent first-use/collector-enable regression test.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Process-wide diagnostic forwarding and subscription synchronization need human sign-off, with Windows, .NET Framework, and WAM runtime validation still outstanding.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Subscription concurrency and accepted process-wide privacy trade-offs warrant human sign-off, with Windows/.NET Framework and WAM runtime validation still outstanding.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making changes related to my previous feedback. I think this updated approach is simpler. The Azure-Identity listener is still quite complicated though, and could use expanded comments/docs. I'll continue my review once that is added.
- Add class, field, and method-body docs to AzureAuthenticationEventListener.
- Expand listener initialization comment in the provider.
- Include the authentication method in SqlClient token events.
- Parse MSAL correlation IDs with TryParseExact("D").
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 9881423d-614d-429e-ba7d-612fbfbcb52e
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Process-wide forwarding and reentrant subscription management warrant human review, with Windows/.NET Framework and WAM runtime validation still outstanding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public API 🆕Issues/PRs that introduce new APIs to the driver.
5 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add authentication diagnostics to the Azure extension through SqlClient's EventSource. No callbacks, no PII.
AuthenticationTracekeyword (0x2000) toMicrosoft.Data.SqlClient.EventSource. Auth events (IDs 22–27) use only this keyword, so they can be collected on their own or together with ordinaryTrace(0x2002).message,source(SqlClient,MSAL,Azure-Identity) andconnectionId.EventListenersamples; document usage, privacy and known limitations in the package README.Collect with:
Suggested release note: Azure extension authentication diagnostics (MSAL, Azure.Identity and token acquisition) can be collected with the new
AuthenticationTraceEventSource keyword.Issues
Fixes #1846.
Testing
Executed on macOS with .NET 10:
Passed: 104; skipped: 12; failed: 0.
All passed. net462 tests compiled, not executed.
Live Azure SQL captures with
dotnet-trace(0x2000:5):ActiveDirectoryDefault: connected; 7 auth-only events (start, skipped chain credentials,AzureCliCredentialselected, success), one connection ID, no ordinary Trace events, none lost.ActiveDirectoryManagedIdentity(no MI on host): expected failure; 41 events including MSAL MI flow, the Azure.Identity failure and SqlClientToken acquisition failed., one connection ID.ActiveDirectoryInteractive(earlier run): connected; MSAL and SqlClient events correlated by connection ID.Not run: Windows/.NET Framework runtime, WAM broker, and performance measurements.
Guidelines
Please review the contribution guidelines before submitting a pull request: