-
Notifications
You must be signed in to change notification settings - Fork 285
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
SqlException: Login failed for user '<token-identified principal>'. #970
Comments
Hi @TresaL I'm hoping your connection string is static and database(s) you connect to all recognize the User Identity being used here? e.g. ensure your connection string always contains name of database you're connecting to, lack of Catalog connects to master which may not recognize your user account. From driver perspective, a new access token is directly fetched from IMDS when a new connection is made. When pooling connections, the same access token will be used until it's expiry and then it's renewed from IMDS again. But if you don't modify your connection string and same connection string fails intermittently you could reach out to Azure Support for any possible network issues in your environment. They can also provide you insights for any resource limits if they exist in your subscription. Also, could you also provide more info on what is your connection usage like and the pattern of intermittent failures so we can try to reproduce it too? If you could wrap up a repro would also be of great help! |
Hi @cheenamalhotra , But it happens every 2nd or 3rd day. I'll enable retry on this error and see whether it helps. but what happen in driver when this error occur? Does it remove the connection from pool? and what is the default expiry of access token when fetched from IMDS? Also the stack trace origin from Thanks, |
Closing as stale and inactive. |
Hi,
I'm using ef core 3.1.2 with .net core 3.1 which uses Microsoft.Data.SqlClient 2.1.1 to run scheduled tasks on azure function under consumption plan. I use azure managed user identity to connect to Azure SQL server. My connection string is like:
Server={serverModel.DatabaseServerName}; Authentication=Active Directory Managed Identity; User Id={userIdentityId}; Database={serverModel.DatabaseName};
I'm intermittently facing SQL Exception as below:
Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user ''.
Inner exception Microsoft.Data.SqlClient.SqlException handled at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw:
at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.SqlClient.SqlConnection.TryOpen (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.SqlClient.SqlConnection.Open (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Microsoft.Data.SqlClient.SqlConnection.Open (Microsoft.Data.SqlClient, Version=2.0.20168.4, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5)
at Core.Repository.WritableDatabaseContext.ExecuteReader (Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: /home/vsts/work/1/s/Core/Repository/WritableDatabaseContext.csCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 83)
My ef db context is like:
The exception occurred at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod. Why this method returns SQL exception with Login failed message? Probably, I might have reached any resource limitation on consumption plan?
Any inside on this is much appreciated.
The text was updated successfully, but these errors were encountered: