Intemittent Login failed for user '<token-identified principal>'.","details":"SqlException: Login failed for user '<token-identified principal>

mustafa altunok 10 Reputation points
2024-07-19T07:35:14.8533333+00:00

Hello. We've an API running on Azure App Service that uses user assigned managed identity to authenticate against an Azure SQL DB.

The app works most of the time, no problem with authentication, however, we get an intermittent authentication issue like the one below:

Login failed for user '<token-identified principal>'.","details":"SqlException: Login failed for user '<token-identified principal>

Azure SQL Database
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,879 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,066 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 25,866 Reputation points
    2024-07-19T19:28:34.64+00:00

    Did you check the logs from both the Azure SQL Database and the App Service for patterns and specific times of failures?

    You need to verify that the managed identity token is refreshed before it expires and that all instances of the App Service are correctly configured to use the managed identity, especially if scaling or instance restarts are involved.

    Also, check if your managed identity has the necessary permissions on the SQL Database.

    Verify if you have followed the steps mentioned in the standard documentation without any issue:

    https://learn.microsoft.com/en-us/azure/data-factory/connector-azure-sql-managed-instance?tabs=data-factory#managed-identity

    and successfully provisioned a Microsoft Entra administrator https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure?view=azuresql&tabs=azure-powershell#provision-azure-ad-admin-sql-managed-instance for your Managed Instance?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.