Repository navigation
How can I override/modify "Active Directory Default" credential behavior? #4539
Unanswered
Astrophizz
asked this question in
Q&A
Replies: 1 comment
|
No code needed. "Active Directory Default" just builds a plain DefaultAzureCredential, and that reads the AZURE_TOKEN_CREDENTIALS env var. Set it to $env:AZURE_TOKEN_CREDENTIALS = "dev"Put it in launchSettings.json for local runs and leave it unset in Azure where you actually want MI. |
0 replies
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