0
votes

I am trying to connect to SQL Server (on Azure VM) from Azure Databricks. I tried connecting using Python and Scala, but failed to connect.

I get the error:

The TCP/IP connection to the host HOSTNAME, port 1433 has failed.

I used the code in the following link: https://docs.databricks.com/data/data-sources/sql-databases.html

Both the SQL Server and the Databricks are on the same VNET.

I tried connecting to the SQL Server using "username" and "pwd" and I am able to connect from Management Studio on a Windows laptop.

val jdbcUrl = s"jdbc:sqlserver://${jdbcHostname}:${jdbcPort};database=${jdbcDatabase}"

I have the following details:

  1. Server Name - ABCD\EFGH (this is what I use to connect from Management Studio on Windows)
  2. IP Address
  3. I am using the default port 1433
  4. Fully qualified name - ABCD.lalaland.lala.lala.la
  5. Database name
  6. Username / pwd

What am I missing? What should the hostname be in JDBC URL? Should the instance name be included?

1
what's error message when connect failed?Leon Yue
@Leon Yue: Apologies, forgot to mention. I get an error saying TCP/IP connection to hostname and port failed. Verify the connection properties and make sure TCP connections to the port are not blocked by firewall.learner
try enabling service endpoints on the vnet hosting both your sql server as well as your databricks instance have you also checked the fw and ntwk rules on your sql server instance itself as well?samuelsaumanchan

1 Answers

0
votes

According to the Subnets reqirement, the virtual network must include two subnets dedicated to Azure Databricks: a private subnet and public subnet. As @samuelsaumanchan said, you can try enabling service endpoints on the vnet hosting both your sql server as well as your databricks instance. Service Endpoints enables private IP addresses in the VNet to reach the endpoint of an Azure service without needing a public IP address on the VNet.