Skip to content

Reference Microsoft.Data.SqlClient.Extensions.Azure in SqlServer client integrations for Entra ID auth#18149

Open
0xharkirat wants to merge 1 commit into
microsoft:mainfrom
0xharkirat:fix/sqlserver-entra-id-auth-provider
Open

Reference Microsoft.Data.SqlClient.Extensions.Azure in SqlServer client integrations for Entra ID auth#18149
0xharkirat wants to merge 1 commit into
microsoft:mainfrom
0xharkirat:fix/sqlserver-entra-id-auth-provider

Conversation

@0xharkirat

@0xharkirat 0xharkirat commented Jun 12, 2026

Copy link
Copy Markdown

Description

Fixes #18148.

Microsoft.Data.SqlClient 7.0 moved the Microsoft Entra ID (Active Directory) authentication providers out of the core driver into the separate Microsoft.Data.SqlClient.Extensions.Azure package. Aspire's Aspire.Hosting.Azure.Sql integration emits a connection string using Authentication="Active Directory Default" by default, but the client integrations that consume it don't reference the provider package, so deployed apps using managed identity against Azure SQL throw Cannot find an authentication provider for 'ActiveDirectoryDefault' at runtime. It passes local dev (the container path uses SQL auth) and only fails in production.

This adds Microsoft.Data.SqlClient.Extensions.Azure to both SqlServer client integrations so Entra connection strings work out of the box:

  • Directory.Packages.props: central PackageVersion 1.0.0 (companion release to the pinned SqlClient 7.0.1).
  • Aspire.Microsoft.Data.SqlClient and Aspire.Microsoft.EntityFrameworkCore.SqlServer: package reference (explicit in both; EF gets SqlClient only transitively and would not otherwise get the provider).
  • README note in both integrations documenting the behavior and the resulting transitive Azure.Identity.
  • A regression test in each test project asserting SqlAuthenticationProvider.GetProvider(...) resolves for ActiveDirectoryDefault / ActiveDirectoryManagedIdentity. Both fail before the change and pass after; full suites pass with no regressions.

Trade-off: these integrations now pull Azure.Identity transitively onto all consumers (including non-Entra users). This is the unavoidable cost of out-of-the-box managed-identity support and restores pre-7.0 behavior; no AOT/trim regression (both already IsAotCompatible=false), and it's consistent with sibling Aspire Azure integrations that already bundle Azure.Identity.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 12, 2026 07:08
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18149

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18149"

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR ensures that Microsoft Entra ID (Active Directory) authentication works out of the box with the Aspire SQL Server integrations after Microsoft.Data.SqlClient 7.0 moved the Entra ID authentication providers into a separate package (Microsoft.Data.SqlClient.Extensions.Azure).

Changes:

  • Adds a reference to Microsoft.Data.SqlClient.Extensions.Azure (v1.0.0) in both the Aspire.Microsoft.Data.SqlClient and Aspire.Microsoft.EntityFrameworkCore.SqlServer component projects so Entra ID auth providers self-register automatically.
  • Adds regression tests verifying that ActiveDirectoryDefault and ActiveDirectoryManagedIdentity authentication providers are registered.
  • Documents the Entra ID authentication behavior and the new transitive dependency in both components' README files.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Directory.Packages.props Pins Microsoft.Data.SqlClient.Extensions.Azure at version 1.0.0 in central package management.
Aspire.Microsoft.Data.SqlClient.csproj Adds Microsoft.Data.SqlClient.Extensions.Azure package reference with explanatory comment.
Aspire.Microsoft.EntityFrameworkCore.SqlServer.csproj Adds Microsoft.Data.SqlClient.Extensions.Azure package reference with explanatory comment.
Aspire.Microsoft.Data.SqlClient/README.md Documents Entra ID auth support and the new transitive Azure.Identity dependency.
Aspire.Microsoft.EntityFrameworkCore.SqlServer/README.md Documents Entra ID auth support and the new transitive Azure.Identity dependency.
AspireSqlServerSqlClientExtensionsTests.cs Adds regression test confirming Entra ID auth providers are registered.
AspireSqlServerEFCoreSqlClientExtensionsTests.cs Adds regression test confirming Entra ID auth providers are registered.

@0xharkirat 0xharkirat force-pushed the fix/sqlserver-entra-id-auth-provider branch from bfde849 to c77158b Compare June 12, 2026 07:20
Microsoft.Data.SqlClient 7.0 moved the Microsoft Entra ID (Active
Directory) authentication providers out of the core driver and into the
separate Microsoft.Data.SqlClient.Extensions.Azure package. Aspire's
Azure SQL hosting integration emits connection strings using
Authentication="Active Directory Default" by default, so without that
package, consuming apps fail at runtime with:
"Cannot find an authentication provider for 'ActiveDirectoryDefault'".
This passes local dev (the SQL container uses SA-password auth) and only
surfaces in production against Azure SQL.

Add the package reference to the Aspire.Microsoft.Data.SqlClient and
Aspire.Microsoft.EntityFrameworkCore.SqlServer client integrations (plus
a central PackageVersion). The EF integration only references SqlClient
transitively, so it needs the explicit reference too. The package
self-registers the providers (the driver lazy-loads the extension
assembly on the first GetProvider lookup). Document the behavior in both
integration READMEs and add a regression test to each test project that
asserts SqlAuthenticationProvider.GetProvider resolves for
ActiveDirectoryDefault and ActiveDirectoryManagedIdentity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@0xharkirat 0xharkirat force-pushed the fix/sqlserver-entra-id-auth-provider branch from c77158b to 1eb5333 Compare June 12, 2026 07:27
Copilot AI review requested due to automatic review settings June 12, 2026 07:27

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 7 out of 7 changed files in this pull request and generated no new comments.

@0xharkirat 0xharkirat requested a review from Copilot June 12, 2026 07:29

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 7 out of 7 changed files in this pull request and generated no new comments.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SqlServer client integrations missing Microsoft.Data.SqlClient.Extensions.Azure for Entra ID auth

2 participants