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
{{ message }}
Repository navigation
Provide an option for embedded or system browser with Azure interactive authentication #2611
Azure interactive logins call the MSAL function AcquireTokenInteractive. The source code comments clearly explain the differences in default behaviour between browsers and .NET versions vis whether an embedded browser or the system browser is used for login. But in all cases, SqlClient does use the default behaviour of MSAL.
It would be better if the consumer application could choose whether an integrated or system browser is used, and this is supported by MSAL via WithUseEmbeddedWebView. What is missing is an option for the consumer to choose the behaviour here.
There is currently no alternative apart from to accept the default, or fork SqlClient and make the change ourselves.
At a higher level, this same feature was added to Azure.Identity based on our feature request so I believe that shows the worth in the idea. It's not an option here since SqlClient uses MSAL directly without an intermediate library (as far as I can tell).
Hello, just wondering if there is any traction on this issue? It comes from a real business need.
The customer environment has conditional access configured on access to Azure SQL resources, and only a specific set of device IDs are allowed to access it. If staff are using firefox or chrome, the device ID does not get sent on and in the Azure sign in logs it shows as device unknown, therefore the staff are prevented from accessing the resource and unable to login. If we set Edge as the default browser - Edge does pass on the device ID and staff can login.
It leaves two options: turn off conditional access, or force users to set their default browser to Edge.
Consider that this used to work with the application modal prompt - it's only since updating to .NET Core that we got the new behaviour of using the system browser that broke this use case.
When I complained about the reverse problem with Azure.Identity (I wanted the browser popup option instead of the application popup on .NET Framework), they implemented the controls on top of MSAL to allow us to choose which method worked best for us. The same control here would be appreciated.
Any traction on this issue? From my side, I've resorted to patching MSAL using Harmony. It's basically a two-line change to get this functionality, plus whatever boilerplate you need on top to make it configurable. It would be appreciated if this was an option in SqlClient.
using Microsoft.Data.SqlClient;
using Microsoft.Identity.Client;
using System;
using System.Threading.Tasks;
namespace CustomAuthProvider
{
public class CustomInteractiveAuthProvider : SqlAuthenticationProvider
{
const string s_clientId = "your-client-id-here"; // Replace with your registered app/client ID
public override async Task<SqlAuthenticationToken> AcquireTokenAsync(SqlAuthenticationParameters parameters)
{
// Implement custom MSAL Interactive authentication logic here
// For example:
var app = PublicClientApplicationBuilder.Create(s_clientId)
.WithAuthority(parameters.Authority)
.WithRedirectUri("http://localhost")
.Build();
string scope = parameters.Resource.EndsWith("/.default", StringComparison.Ordinal) ? parameters.Resource : parameters.Resource + "/.default";
string[] scopes = new string[] { scope };
var result = await app.AcquireTokenInteractive(scopes).WithUseEmbeddedWebView(true).ExecuteAsync();
if (string.IsNullOrEmpty(result.AccessToken))
{
throw new Exception("Access token is not provided.");
}
return new SqlAuthenticationToken(result.AccessToken, result.ExpiresOn);
}
public override bool IsSupported(SqlAuthenticationMethod authenticationMethod)
{
return authenticationMethod.Equals(SqlAuthenticationMethod.ActiveDirectoryInteractive);
}
}
}
Area\Netcore (Azure AD/Entra ID interactive authentication via ActiveDirectoryAuthenticationProvider, MSAL AcquireTokenInteractive browser selection)
Duplicates
None found
Regression
Not indicated as a regression per se, but a real behavior change was noted: the reporter states the previous "application modal prompt" (embedded browser) behavior on .NET Framework was replaced by system-browser behavior on .NET Core, which broke a conditional-access/device-ID scenario. This is a default-behavior change across frameworks rather than a version-boundary bug.
Analysis
The request asks that Microsoft.Data.SqlClient expose a connection-string or API-level option to select embedded vs. system browser for Authentication=ActiveDirectoryInteractive, mirroring MSAL's WithUseEmbeddedWebView and the equivalent feature already added to Azure.Identity. Currently ActiveDirectoryAuthenticationProvider.cs relies on MSAL's default browser-selection behavior with no consumer override, forcing users to fork the library or implement a custom SqlAuthenticationProvider (a workaround already documented by a maintainer in this thread). This has a real business impact (conditional access / device ID policies) reported by multiple commenters over ~18 months. Severity: P2 (valid, low-risk feature enhancement with existing workaround, moderate community interest).
Next Steps
A maintainer has already provided a documented workaround (custom SqlAuthenticationProvider overriding AcquireTokenAsync with WithUseEmbeddedWebView), which unblocks affected consumers today. This should continue to be pointed to for anyone hitting this in the interim.
Recommend assigning to Copilot coding agent to implement a first-class option: add a new SqlConnectionStringBuilder/SqlAuthenticationParameters setting (e.g. Use Embedded Web View or similar) that flows through ActiveDirectoryAuthenticationProvider.cs to PublicClientApplication.AcquireTokenInteractive(...).WithUseEmbeddedWebView(bool). Investigation should cover: (1) adding the new connection string keyword and its parser/builder wiring, (2) updating SqlAuthenticationParameters to carry the flag, (3) default value selection to preserve current behavior for backward compatibility, (4) updates to ref/ reference assemblies since this is a public API surface change, and (5) unit/functional tests plus a doc/samples/ sample demonstrating the new option.
Since this is a public API addition, ensure the change is reviewed against .github/instructions/api-design.instructions.md guidance before implementation.
Note: This triage summary is auto-generated by an AI agent. The analysis and suggestions above have not been verified by a human maintainer. Please treat as preliminary guidance only.
Activity
arellegue commentedon Jun 27, 2024
We will discuss this and see it is feasible then back to you.
thenextman commentedon Jan 15, 2025
Hello, just wondering if there is any traction on this issue? It comes from a real business need.
The customer environment has conditional access configured on access to Azure SQL resources, and only a specific set of device IDs are allowed to access it. If staff are using firefox or chrome, the device ID does not get sent on and in the Azure sign in logs it shows as device unknown, therefore the staff are prevented from accessing the resource and unable to login. If we set Edge as the default browser - Edge does pass on the device ID and staff can login.
It leaves two options: turn off conditional access, or force users to set their default browser to Edge.
Consider that this used to work with the application modal prompt - it's only since updating to .NET Core that we got the new behaviour of using the system browser that broke this use case.
When I complained about the reverse problem with Azure.Identity (I wanted the browser popup option instead of the application popup on .NET Framework), they implemented the controls on top of MSAL to allow us to choose which method worked best for us. The same control here would be appreciated.
thenextman commentedon Apr 19, 2025
Any traction on this issue? From my side, I've resorted to patching MSAL using Harmony. It's basically a two-line change to get this functionality, plus whatever boilerplate you need on top to make it configurable. It would be appreciated if this was an option in SqlClient.
David-Engel commentedon Dec 5, 2025
You can always create a custom provider that overrides the MDS implementation for Authentication=ActiveDirectoryInteractive. There is an example that shows overriding the ActiveDirectoryDeviceCodeFlow option here:
https://learn.microsoft.com/en-us/sql/connect/ado-net/sql/azure-active-directory-authentication?view=sql-server-ver16#support-for-a-custom-sql-authentication-provider
Any of the options can be overridden. You can even override them without app code changes by modifying the app.config.
Example:
app.config
Provider
priyankatiwari08 commentedon Sep 17, 2026
/triage
github-actions commentedon Sep 17, 2026
🔍 Triage Summary (on-demand re-triage)
Area\Netcore(Azure AD/Entra ID interactive authentication viaActiveDirectoryAuthenticationProvider, MSALAcquireTokenInteractivebrowser selection)Analysis
The request asks that
Microsoft.Data.SqlClientexpose a connection-string or API-level option to select embedded vs. system browser forAuthentication=ActiveDirectoryInteractive, mirroring MSAL'sWithUseEmbeddedWebViewand the equivalent feature already added toAzure.Identity. CurrentlyActiveDirectoryAuthenticationProvider.csrelies on MSAL's default browser-selection behavior with no consumer override, forcing users to fork the library or implement a customSqlAuthenticationProvider(a workaround already documented by a maintainer in this thread). This has a real business impact (conditional access / device ID policies) reported by multiple commenters over ~18 months. Severity: P2 (valid, low-risk feature enhancement with existing workaround, moderate community interest).Next Steps
SqlAuthenticationProvideroverridingAcquireTokenAsyncwithWithUseEmbeddedWebView), which unblocks affected consumers today. This should continue to be pointed to for anyone hitting this in the interim.SqlConnectionStringBuilder/SqlAuthenticationParameterssetting (e.g.Use Embedded Web Viewor similar) that flows throughActiveDirectoryAuthenticationProvider.cstoPublicClientApplication.AcquireTokenInteractive(...).WithUseEmbeddedWebView(bool). Investigation should cover: (1) adding the new connection string keyword and its parser/builder wiring, (2) updatingSqlAuthenticationParametersto carry the flag, (3) default value selection to preserve current behavior for backward compatibility, (4) updates toref/reference assemblies since this is a public API surface change, and (5) unit/functional tests plus adoc/samples/sample demonstrating the new option..github/instructions/api-design.instructions.mdguidance before implementation.