Can not connect to Azure SQL DB from Azure Databricks RRS feed

  • Question

  • Hi all,

    I am getting this error when I try to connect to Azure SQL DB from Azure Databricks.

    "Cannot open server "domain.com" requested by the login.  The login failed". Domain.com is not the real domain, I hope you will understand.

    The firewall is already configured, the team who owns the DB whitelisted my IP address and I can connect to the Azure SQL Instance via SSMS. I do not know why I am getting the above message when I try to connect from Azure Databricks. I am trying to run the below script

    import com.microsoft.azure.sqldb.spark.config.Config
    import com.microsoft.azure.sqldb.spark.connect._

    val config = Config(Map(
      "url"            -> "kkkk.database.windows.net:1433",
      "databaseName"   -> "DBName",
      "dbTable"        -> "dbo.tttt",
      "user"           -> "yooooo@domain.com",
      "password"       -> "*******",
      "connectTimeout" -> "5", //seconds
      "queryTimeout"   -> "5"  //seconds
    val collection = spark.read.sqlDB(config)

    Wednesday, November 20, 2019 8:09 PM

All replies

  • Wednesday, November 20, 2019 9:40 PM
  • The link that Gonzalo provides has three options for connecting from Azure Databricks: 1) JDBC 2) Python 3) Spark

    Please let us know if you have any questions.



    Wednesday, November 20, 2019 11:11 PM
  • Hi Gonzalo and Mike

    I have tried the steps in the link but still getting the same error message when I finally try to read the table

    "Cannot open server "domain.com" requested by the login.  The login failed."

    I can connect to the database and read from the tables from SSMS. I do not know why it is showing error from Databricks.

    Friday, November 22, 2019 11:51 PM
  • Hi Jonas,

    Are you using Azure Active Directory authentication or SQL Authentication?

    I believe the issue is that the user value is not correct, where domain.com cannot be resolved...hence the error.

    "user"           -> "yooooo@domain.com",

    Please see: Connect Spark to SQL DB using the connector for SQL Authentication.

    If you are using Azure Active Directory Authentication, please see: Connect Spark to Azure SQL Database using AAD authentication

    If you are using SQL Authentication, please drop the domain.com value. If you are using AAD authentication, you use @domain.com only if it refers to an individual in the tenant. If you are referencing a Managed Identity in the tenant (i.e. a securoty group) you use only the Managed Identity name without @domain.com. I believe that is the case when connecting from Azure Databricks.

    Please let us know what you find, and what the solution is to this issue. It is helpful as I have seen this before.



    Thursday, November 28, 2019 2:13 AM