How can I override/modify "Active Directory Default" credential behavior? #4539
Unanswered
Astrophizz
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This is in Q&A though I mistakenly got the answer from the Azure/azure-sdk-for-net repository.
There's an issue in Azure.Core 1.60.0+ where the
DefaultAzureCredentialfails to attempt to authenticate beyondManagedIdentityCredential. The direct workaround is to (in the appropriate context) setExcludeManagedIdentityCredential = trueinDefaultAzureCredentialOptions. I didn't know how to apply that toMicrosoft.Data.SqlClient.Extensions.Azurethough.The
Microsoft.Data.SqlClient.Extensions.Azure-specific workaround/answer is that there is anAccessTokenCallbackproperty inSqlConnectionthat I can have return a token generated from aDefaultAzureCredentialwithExcludeManagedIdentityCredential = trueandTokenRequestContext(["https://database.windows.net/.default"].See also: Connect to Azure SQL with Microsoft Entra authentication and SqlClient: Using AccessTokenCallback
All reactions