We are using the Microsoft JDBC driver to connect to Azure SQL Database with Authentication=ActiveDirectoryServicePrincipal.
The connection works most of the time, but we are seeing intermittent failures during authentication with the following error:
com.microsoft.sqlserver.jdbc.SQLServerException: Failed to authenticate the user <client-id> in Active Directory (Authentication=ActiveDirectoryServicePrincipal).
Caused by: java.net.ConnectException: Connection timed out
Stack trace (relevant part):
at com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils.getSqlFedAuthTokenPrincipal
at com.microsoft.sqlserver.jdbc.SQLServerConnection.getFedAuthToken
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon
at java.sql.DriverManager.getConnection
Key observations:
- This issue is intermittent (same credentials work on retry)
- Happens during token acquisition (MSAL) before SQL login completes
- No changes in client ID / secret
- Same code path sometimes succeeds immediately after failure
Environment:
- Java application using Microsoft JDBC driver
- Authentication: ActiveDirectoryServicePrincipal
- Running in (container/VM – specify if needed)
- Connections are created programmatically (not always pooled)
- Component Where Version mssql-jdbc mt-service/pom.xml 10.2.3.jre17 msal4j Parent pom (dependencyManagement) 1.16.0 msal4j mt-service/pom.xml (direct) 1.30.0-beta
Questions:
- What could cause intermittent timeouts during MSAL token acquisition for service principal auth?
- Are there known issues with JDBC + MSAL4J + Azure AD endpoint connectivity causing this behavior?
- What are recommended best practices for:
- Retry handling for token acquisition failures?
- Tuning loginTimeout or other JDBC properties?
- Are there specific network endpoints or dependencies we should validate for reliability?
Any guidance on diagnosing or stabilizing this would be very helpful.We are using the Microsoft JDBC driver to connect to Azure SQL Database with Authentication=ActiveDirectoryServicePrincipal.We are using the Microsoft JDBC driver to connect to Azure SQL Database with Authentication=ActiveDirectoryServicePrincipal.
The connection works most of the time, but we are seeing intermittent failures during authentication with the following error:
com.microsoft.sqlserver.jdbc.SQLServerException: Failed to authenticate the user <client-id> in Active Directory (Authentication=ActiveDirectoryServicePrincipal).
Caused by: java.net.ConnectException: Connection timed out
Stack trace (relevant part):
at com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils.getSqlFedAuthTokenPrincipal
at com.microsoft.sqlserver.jdbc.SQLServerConnection.getFedAuthToken
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon
at java.sql.DriverManager.getConnection
Key observations:
- This issue is intermittent (same credentials work on retry)
- Happens during token acquisition (MSAL) before SQL login completes
- No changes in client ID / secret
- Same code path sometimes succeeds immediately after failure
Environment:
- Java application using Microsoft JDBC driver
- Authentication: ActiveDirectoryServicePrincipal
- Running in (container/VM – specify if needed)
- Connections are created programmatically (not always pooled)
- Component Where Version
mssql-jdbc mt-service/pom.xml 10.2.3.jre17
msal4j Parent pom (dependencyManagement) 1.16.0
msal4j mt-service/pom.xml (direct) 1.30.0-beta
Questions:
- What could cause intermittent timeouts during MSAL token acquisition for service principal auth?
- Are there known issues with JDBC + MSAL4J + Azure AD endpoint connectivity causing this behavior?
- What are recommended best practices for:
- Retry handling for token acquisition failures?
- Tuning loginTimeout or other JDBC properties?
- Are there specific network endpoints or dependencies we should validate for reliability?
Any guidance on diagnosing or stabilizing this would be very helpful.We are using the Microsoft JDBC driver to connect to Azure SQL Database with Authentication=ActiveDirectoryServicePrincipal.