Search code examples
c#azureodbcazure-databricks

Connecting to Azure Databricks from ASP.NET using ODBC driver


I am exploring an option to access the Azure Databricks SQL tables from ASP.NET MVC application.

In order to achieve that I came across an article where it states to configure ODBC Data Source.

Configure the Databricks ODBC and JDBC drivers

Although, my setup is not successful yet (I am using

Simba Spark 2.6 64-bit.msi

), I keep on facing error as seen in image below. I have made sure that I have right host name and port number as they are in my azure databricks portal.

incorrect host name and port

Alternatively, I tried to configure the ODBC connection setting using System.Data.Odbc DLL in my .net application. But I fear I am missing very minute configuration somewhere in either of these options to work it out. Here is the code so far I found and tried from below link.

Trying to access SQL tables via ODBC in .NET

Any insight to this issue is highly appreciated.


Solution

  • I installed the Simba ODBC DSN Driver and was able to connect to Azure Databricks with the connection string, Refer below:-

    Installed Databricks ODBC Driver in my local machine.

    enter image description here

    Background Image reference:- https://www.databricks.com/spark/odbc-drivers-download

    Went to User DSN clicked on Add > Selected Simba Spark > A new window of Simba Spark ODBC Driver DSN set up appeared and I entered the following details from my Azure Databricks > Compute > Select your Compute > Scroll Down > Advanced > JDBC/ODBC Drivers> Validate the connection string with Hostname, Port and enter the same in the Simba Spark ODBC Driver DSN set up tool:-

    Azure Databricks:-

    enter image description here

    Simba Spark ODBC Driver DSN set up :-

    enter image description here

    Make sure you add User Name as token and add Personal access token in the password. You can generate PAT for your Azure Databricks workspace with the steps below:-

    Click on the Username at the right top > User settings > Generate new token > token name > Generate> Copy the token and save it

    enter image description here

    enter image description here

    enter image description here

    Enable SSL :-

    enter image description here

    Add HTTP path and click Ok :-

    enter image description here

    Got connected to Datasource successfully like below:-

    enter image description here

    When I tried to add the same datasource via System DSN with same parameters, I got the same error code as yours:-

    enter image description here

    Reference:-

    Configure the Databricks ODBC and JDBC drivers | Databricks on AWS