Connect to Azure SQL DB via Active Directory Password

  • 7 September 2023
  • 5 replies

Badge +1



I am trying to connect to an Azure SQL DB with the following connections string:


The issue is that when I run the code, I get the following error:

Exception occurred in command execution. 'Could not Connect to Database. Failed to load MSAL4J Java library for performing ActiveDirectoryPassword authentication.'


Do you know what is to be done? I have searched and found nothing about this.


Thank you


Best answer by ravi.pothana 7 September 2023, 15:47

View original

5 replies

Userlevel 3
Badge +8

Hi @ovdptr,

It seems the the bot runner machine is missing required java library to connect to Azure SQL Database, Before you connect to a SQL Server database, JDBC driver must be installed on the bot agent.


Download the JDBC Driver:

When you download the driver, there are multiple JAR files. The name of the JAR file indicates the version of Java that it supports

Using the JDBC driver:


Hope this helps!


Thank you. 


Badge +1

I have downloaded and set the Classpath as mentioned in the links, yet I receive the same error.

Is there anything that I am missing?

Thank you!

Userlevel 3
Badge +8

“ActiveDirectoryPassword” authentication mode have more requirements, ensure you have required dependent libraries from the Client setup requirements.



Badge +1

I have managed to get through there.

The only issue is that I do not now how to add the MSAL4J part to the BotAgent.

As the JDBC drivers are ok, since the connection to azure with SQL Server conn type worked previously.

Thank you!


Running into this issue as well and not understanding where within AA these changes can be made beyond loading the proper DLL which I’ve made certain is in place.