Microsoft.Data.SqlClient.Extensions.Azure 8.0.0-preview1.26313.4

Prefix Reserved
This is a prerelease version of Microsoft.Data.SqlClient.Extensions.Azure.
dotnet add package Microsoft.Data.SqlClient.Extensions.Azure --version 8.0.0-preview1.26313.4
                    
NuGet\Install-Package Microsoft.Data.SqlClient.Extensions.Azure -Version 8.0.0-preview1.26313.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Data.SqlClient.Extensions.Azure" Version="8.0.0-preview1.26313.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Data.SqlClient.Extensions.Azure" Version="8.0.0-preview1.26313.4" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.Data.SqlClient.Extensions.Azure" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.Data.SqlClient.Extensions.Azure --version 8.0.0-preview1.26313.4
                    
#r "nuget: Microsoft.Data.SqlClient.Extensions.Azure, 8.0.0-preview1.26313.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Microsoft.Data.SqlClient.Extensions.Azure@8.0.0-preview1.26313.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Microsoft.Data.SqlClient.Extensions.Azure&version=8.0.0-preview1.26313.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Microsoft.Data.SqlClient.Extensions.Azure&version=8.0.0-preview1.26313.4&prerelease
                    
Install as a Cake Tool

Microsoft.Data.SqlClient.Extensions.Azure

NuGet NuGet Downloads

Description

This package provides Azure integration extensions for Microsoft.Data.SqlClient. It enables seamless authentication and connectivity with Azure SQL Database using Azure Identity and other Azure services.

Key Features

  • Entra ID Authentication: Simplified Entra ID token-based authentication
  • Managed Identity Support: Connect to Azure SQL using Azure Managed Identities
  • Token Caching: Automatic caching of authentication tokens for improved performance
  • Azure Identity Integration: Use Azure.Identity credential types supplied by Azure.Core
  • Azure Attestation: Validates Microsoft Azure Attestation tokens for Always Encrypted with secure enclaves. Applications that connect with Attestation Protocol=AAS must reference this package.

Supportability

This package targets:

  • .NET Framework 4.6.2 (net462)
  • .NET Standard 2.0 (netstandard2.0)

When used with the current Microsoft.Data.SqlClient driver, supported runtimes are .NET Framework 4.6.2+ and .NET 10.0+. The .NET Standard target does not extend driver runtime support.

Installation

Install the package via NuGet:

dotnet add package Microsoft.Data.SqlClient.Extensions.Azure

Or via the Package Manager Console:

Install-Package Microsoft.Data.SqlClient.Extensions.Azure

Azure.Core migration

This package uses Azure.Core 1.62.0 or later instead of depending on Azure.Identity. Credential types remain in the Azure.Identity namespace, so existing using directives do not need to change.

If your application references Azure.Identity older than 1.21.0, remove that reference or upgrade it to 1.21.0 or later to avoid duplicate-type errors (CS0433). If another dependency brings in an older Azure.Identity transitively, add a direct reference to Azure.Identity 1.21.0 or later, which forwards its types to Azure.Core. Applications using Azure.Identity.Broker must also upgrade it to 1.6.0 or later.

See the Azure SDK migration guide for details.

Getting Started

Connect Using Default Azure Credential

using Microsoft.Data.SqlClient;
using Azure.Identity;

// Use DefaultAzureCredential for automatic authentication
// Works with Managed Identity, Azure CLI, Visual Studio, and more
var credential = new DefaultAzureCredential();

var connectionString = "Server=myserver.database.windows.net;Database=mydb;";

using var connection = new SqlConnection(connectionString);
connection.AccessTokenCallback = async (ctx, cancellationToken) =>
{
    var token = await credential.GetTokenAsync(
        new Azure.Core.TokenRequestContext(new[] { "https://database.windows.net/.default" }),
        cancellationToken);
    return new SqlAuthenticationToken(token.Token, token.ExpiresOn);
};

await connection.OpenAsync();

Connect Using Managed Identity

For applications running in Azure (App Service, Functions, VMs, AKS, etc.):

using Microsoft.Data.SqlClient;
using Azure.Identity;

// Use system-assigned managed identity
var credential = new ManagedIdentityCredential();

// Or use user-assigned managed identity
// var credential = new ManagedIdentityCredential("client-id-of-user-assigned-identity");

var connectionString = "Server=myserver.database.windows.net;Database=mydb;";

using var connection = new SqlConnection(connectionString);
connection.AccessTokenCallback = async (ctx, cancellationToken) =>
{
    var token = await credential.GetTokenAsync(
        new Azure.Core.TokenRequestContext(new[] { "https://database.windows.net/.default" }),
        cancellationToken);
    return new SqlAuthenticationToken(token.Token, token.ExpiresOn);
};

await connection.OpenAsync();

Connect Using Service Principal

For service-to-service authentication:

using Microsoft.Data.SqlClient;
using Azure.Identity;

var credential = new ClientSecretCredential(
    tenantId: "your-tenant-id",
    clientId: "your-client-id",
    clientSecret: "your-client-secret");

var connectionString = "Server=myserver.database.windows.net;Database=mydb;";

using var connection = new SqlConnection(connectionString);
connection.AccessTokenCallback = async (ctx, cancellationToken) =>
{
    var token = await credential.GetTokenAsync(
        new Azure.Core.TokenRequestContext(new[] { "https://database.windows.net/.default" }),
        cancellationToken);
    return new SqlAuthenticationToken(token.Token, token.ExpiresOn);
};

await connection.OpenAsync();

Authentication Methods

Authentication Type Credential Class Use Case
Default DefaultAzureCredential Development and production with automatic credential chain
Managed Identity ManagedIdentityCredential Azure-hosted applications
Service Principal ClientSecretCredential Service-to-service authentication
Certificate ClientCertificateCredential Certificate-based service auth
Interactive InteractiveBrowserCredential Interactive user authentication
Azure CLI AzureCliCredential Local development
Visual Studio VisualStudioCredential Development in Visual Studio

Interactive authentication in windowless Windows hosts

On Windows, Authentication=Active Directory Interactive uses Web Account Manager (WAM) with SqlClient's built-in Microsoft application ID. WAM requires a valid parent window handle when interactive sign-in is needed. A local Azure Functions worker can lack a console window even when its developer is using an interactive desktop.

For windowless local development, use Authentication=Active Directory Default with a configured developer credential, such as an Azure CLI or Visual Studio sign-in. For Azure-hosted Functions, prefer managed identity.

If the application owns a suitable window, supply its handle through ActiveDirectoryAuthenticationProvider.SetParentActivityOrWindowFunc before opening connections. Do not use an unrelated application's window.

If interactive sign-in without WAM is required, register your own Entra application and supply its client ID with UseWamBroker = false. Setting UseWamBroker = false alone does not disable WAM for SqlClient's first-party application ID. On modern .NET, configure a public client/native redirect URI of http://localhost for system-browser authentication and the Azure SQL Database delegated user_impersonation permission, with consent as required by your tenant. The signed-in user must also have database access.

See the custom application ID sample and the MSAL parent window requirements.

Authentication Logging

The built-in Entra ID provider writes non-PII MSAL, Azure.Identity, and SqlClient token acquisition diagnostics to Microsoft.Data.SqlClient.EventSource under the AuthenticationTrace keyword (0x2000). No code change or logging callback is needed. Collectors choose the level and can attach to a running application.

Collect authentication events only, at Verbose level:

dotnet-trace collect --process-id <pid> \
  --providers Microsoft.Data.SqlClient.EventSource:0x2000:5 \
  --rundown false
Keyword mask Collects
0x2000 Authentication events only
0x2 Ordinary SqlClient Trace events only
0x2002 Both

Use level 4 for Informational and above, or 5 for Verbose. Each event has message, source (MSAL, Azure-Identity, or SqlClient), and connectionId. dotnet-trace works on modern .NET. On .NET Framework, use an ETW collector or an in-process EventListener with the same keyword and level.

Privacy:

  • PII logging stays disabled for MSAL. There is no PII opt-in.
  • For Default, Managed Identity, Service Principal, and Workload Identity, Azure.Identity unsafe support logging, account-identifier logging, and HTTP content logging stay disabled.
  • Only known Azure.Identity events are forwarded. Raw SDK exception payloads are not forwarded.
  • Treat trace files as sensitive operational data.

Known limitations:

  • DefaultAzureCredential logs one Azure credential token request failed. error for each credential it tries and skips, even when a later credential succeeds. Use the DefaultAzureCredential selected ... event and the final SqlClient result to read the outcome.
  • MSAL error messages can include exception text and stack details produced by MSAL.
  • Correlation is best effort. SqlClient and MSAL events for the built-in MSAL flows carry the connection ID. Azure.Identity token failures carry it only when SqlClient made the request. Other Azure.Identity events (MSAL text from Azure credentials and DefaultAzureCredential selected ...) have no request ID and use an empty connection ID (00000000-0000-0000-0000-000000000000).
  • Uncorrelated Azure.Identity events can come from Azure credentials the application uses in the same process. If the application enables IsUnsafeSupportLoggingEnabled on its own credentials, that output can appear in these traces.
  • Credentials created by the application for AccessTokenCallback are not covered. Use Azure.Identity logging for those credentials.
  • Cached tokens and pooled connections can skip authentication, so an open does not always produce events.

Samples: dotnet-trace and EventListener. See issue #1846.

Documentation

License

This package is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (49)

Showing the top 5 NuGet packages that depend on Microsoft.Data.SqlClient.Extensions.Azure:

Package Downloads
Umbraco.Cms

Installs Umbraco CMS with all default dependencies in your ASP.NET Core project.

Aspire.Microsoft.EntityFrameworkCore.SqlServer

A Microsoft SQL Server provider for Entity Framework Core that integrates with Aspire, including connection pooling, health check, logging, and telemetry.

Umbraco.Cms.Persistence.SqlServer

Adds support for SQL Server to Umbraco CMS.

Umbraco.Cms.Persistence.EFCore.SqlServer

Adds support for Entity Framework Core SQL Server migrations to Umbraco CMS.

Kros.Utils

General utilities and helpers.

GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on Microsoft.Data.SqlClient.Extensions.Azure:

Repository Stars
dotnet/efcore
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
dotnet/dotnet
Home of .NET's Virtual Monolithic Repository which includes all the code needed to build the .NET SDK.
erikdarlingdata/PerformanceMonitor
Free, open-source SQL Server and Postgres performance monitoring. Collectors, real-time alerts, graphical plan viewer, MCP server for AI analysis. Supports SQL 2016-2025, Azure SQL, AWS RDS, Postgres, Aurora Postgres.
trimble-oss/dba-dash
DBA Dash - SQL Server Monitoring Tool
erikdarlingdata/PerformanceStudio
Free, open-source SQL Server execution plan analyzer — cross-platform GUI + CLI with 30 analysis rules, missing index detection, SSMS extension. Built-in MCP server for AI-assisted plan review.
Version Downloads Last Updated
8.0.0-preview1.26313.4 140 11/9/2026
7.1.2 37,562 11/13/2026
7.1.1 2,105,892 9/29/2026
7.1.0 511,976 9/18/2026
7.1.0-preview3.26238.4 1,260 8/27/2026
7.1.0-preview2.26190.5 4,305 7/10/2026
7.0.4 419 11/13/2026
7.0.3 384,299 9/10/2026
7.0.2 5,178,758 6/25/2026
1.0.0 6,973,217 3/17/2026
1.0.0-preview1.26064.3 575 3/5/2026