-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection Open() having delay in establishing connection using Managed Identity Authentication #2149
Comments
@ronyabrahammathew thank you for reporting this issue. We will look into this and will get back to you. |
|
Questions on this:
As @David-Engel points out, the "Azure Directory Default" leans on DefaultAzureCredential from MSAL .. which in turn iterates through a series of credentialing methods until it finds one that works. It starts with EnvironmentCredential, then WorkloadCredential then ManagedIdentityCredential. It's possible delays to getting a token for a given ManagedIdentity could come from the underlying IMDS (Instance MetaData Service) that provides the token. Usually delays from IMDS come from overloading the service too many requests for tokens in a short period of time. There are SLAs and limits for how many tokens be requested at once. Although I would imagine this is unlikely given your running a single query. Unless of course the VM you tested from (if it was a VM) was running other workloads. |
Describe the bug
We are seeing 14-15 sec time delay in establishing connection to Azure SQL database using Managed Identity access from .Net console application as well as Azure Function App when we are using Open().
But while using Database service account to connect to Azure SQL with the same open() it is taking less than 1 sec for connection establishment.
For the MI access, while using OpenAsync() the connection establishment is much more faster compared to the Open(). We need to understand why Open() is causing an issue.
To reproduce
Below is the code piece we were using for testing connection. We removed the server/db/user/password related information form the connection string
Expected behavior
In ideal scenario, while using Open() the connection establishment shouldn't take more than 1 sec
Further technical details
Microsoft.Data.SqlClient version: 5.1.1
.NET target: .Net 6.0
SQL Server version: Azure SQL Server 12.0.2000.8
Operating system: Windows 10 Enterprise
Additional context
We are a Unified Support customer. We are facing issue on the connection establishment from our Azure function app to Azure sql server using the MI authentication. As part of the issue, we have an active MS ticket to resolve the issue.
Tagging @AshleyGrant
The text was updated successfully, but these errors were encountered: