VOOZH about

URL: https://www.cdata.com/kb/tech/azuredatalake-cloud-databricks.rst

⇱ Connect and Query Live Azure Data Lake Storage Data in Databricks with CData Connect AI


Connect and Query Live Azure Data Lake Storage Data in Databricks with CData Connect AI

👁 Mohsin Turki
Mohsin Turki
Technical Marketing Engineer
Use CData Connect AI to integrate live Azure Data Lake Storage data into Databricks and enable direct, live querying and analysis without replication.

Databricks is a leading AI cloud-native platform that unifies data engineering, machine learning, and analytics at scale. Its powerful data lakehouse architecture combines the performance of data warehouses with the flexibility of data lakes. Integrating Databricks with CData Connect AI gives organizations live, real-time access to Azure Data Lake Storage data without the need for complex ETL pipelines or data duplication—streamlining operations and reducing time-to-insights.

In this article, we'll walk through how to configure a secure, live connection from Databricks to Azure Data Lake Storage using CData Connect AI. Once configured, you'll be able to access Azure Data Lake Storage data directly from Databricks notebooks using standard SQL—enabling unified, real-time analytics across your data ecosystem.

Overview

Here is an overview of the simple steps:

  1. Step 1 — Connect and Configure: In CData Connect AI, create a connection to your Azure Data Lake Storage source, configure user permissions, and generate a Personal Access Token (PAT).
  2. Step 2 — Query from Databricks: Install the CData JDBC driver in Databricks, configure your notebook with the connection details, and run SQL queries to access live Azure Data Lake Storage data.

Prerequisites

Before you begin, make sure you have the following:

  1. An active Azure Data Lake Storage account.
  2. A CData Connect AI account. You can log in or sign up for a free trial here.
  3. A Databricks account. Sign up or log in here.

Step 1: Connect and Configure a Azure Data Lake Storage Connection in CData Connect AI

1.1 Add a Connection to Azure Data Lake Storage

CData Connect AI uses a straightforward, point-and-click interface to connect to available data sources.

  1. Log into Connect AI, click Sources on the left, and then click Add Connection in the top-right.
  2. 👁 Adding a Connection in CData Connect AI
  3. Select "Azure Data Lake Storage" from the Add Connection panel.
  4. 👁 Selecting a data source
  5. Enter the necessary authentication properties to connect to Azure Data Lake Storage.

    Authenticating to a Gen 1 DataLakeStore Account

    Gen 1 uses OAuth 2.0 in Entra ID (formerly Azure AD) for authentication.

    For this, an Active Directory web application is required. You can create one as follows:

    1. Sign in to your Azure Account through the
    2. Select "Entra ID" (formerly Azure AD).
    3. Select "App registrations".
    4. Select "New application registration".
    5. Provide a name and URL for the application. Select Web app for the type of application you want to create.
    6. Select "Required permissions" and change the required permissions for this app. At a minimum, "Azure Data Lake" and "Windows Azure Service Management API" are required.
    7. Select "Key" and generate a new key. Add a description, a duration, and take note of the generated key. You won't be able to see it again.

    To authenticate against a Gen 1 DataLakeStore account, the following properties are required:

    • Schema: Set this to ADLSGen1.
    • Account: Set this to the name of the account.
    • OAuthClientId: Set this to the application Id of the app you created.
    • OAuthClientSecret: Set this to the key generated for the app you created.
    • TenantId: Set this to the tenant Id. See the property for more information on how to acquire this.
    • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.

    Authenticating to a Gen 2 DataLakeStore Account

    To authenticate against a Gen 2 DataLakeStore account, the following properties are required:

    • Schema: Set this to ADLSGen2.
    • Account: Set this to the name of the account.
    • FileSystem: Set this to the file system which will be used for this account.
    • AccessKey: Set this to the access key which will be used to authenticate the calls to the API. See the property for more information on how to acquire this.
    • Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.
    👁 Configuring a connection (Salesforce is shown)
  6. Click Save & Test in the top-right.
  7. Navigate to the Permissions tab on the Azure Data Lake Storage Connection page and update the user-based permissions based on your preferences. 👁 Updating permissions

1.2 Generate a Personal Access Token (PAT)

When connecting to Connect AI through the REST API, the OData API, or the Virtual SQL Server, a Personal Access Token (PAT) is used to authenticate the connection to Connect AI. PAT functions as an alternative to your login credentials for secure, token-based authentication. It is a best practice to create a separate PAT for each service to maintain granularity of access.

  1. Click on the Gear icon () at the top right of the Connect AI app to open the settings page.
  2. On the Settings page, go to the Access Tokens section and click Create PAT.
  3. Give the PAT a name and click Create. 👁 Creating a new PAT
  4. Note: The personal access token is only visible at creation, so be sure to copy it and store it securely for future use.

Step 2: Connect and Query Azure Data Lake Storage Data in Databricks

Follow these steps to establish a connection from Databricks to Azure Data Lake Storage. You'll install the CData JDBC Driver for Connect AI, add the JAR file to your cluster, configure your notebooks, and run SQL queries to access live Azure Data Lake Storage data data.

2.1 Install the CData JDBC Driver for Connect AI

  1. In CData Connect AI, click the Integrations page on the left. Search for JDBC or Databricks, click Download, and select the installer for your operating system.
  2. Once downloaded, run the installer and follow the instructions:
    • For Windows: Run the setup file and follow the installation wizard.
    • For Mac/Linux: Unpack the archive and move the folder to /opt or /Applications. Make sure you have execute permissions.
  3. After installation, locate the JAR file in the installation directory:
    • Windows:
      C:\Program Files\CData\CData JDBC Driver for Connect AI\lib\cdata.jdbc.connect.jar
    • Mac/Linux:
      /Applications/CData/CData JDBC Driver for Connect AI/lib/cdata.jdbc.connect.jar

2.2 Install the JAR File on Databricks

  1. Log in to Databricks. In the navigation pane, click Compute on the left. Start or create a compute cluster. 👁 Launching a compute cluster in Databricks
  2. Click on the running cluster, go to the Libraries tab, and click Install New at the top right. 👁 Accessing the Libraries tab in Databricks
  3. In the Install Library dialog, select DBFS, and drag and drop the cdata.jdbc.connect.jar file. Click Install. 👁 Uploading the JDBC driver JAR to DBFS

2.3 Query Azure Data Lake Storage Data in a Databricks Notebook

Notebook Script 1 — Define JDBC Connection:

  1. Paste the following script into the notebook cell:
driver = "cdata.jdbc.connect.ConnectDriver"
url = "jdbc:connect:AuthScheme=Basic;User=your_username;Password=your_pat;URL=https://cloud.cdata.com/api/;DefaultCatalog=Your_Connection_Name;"
  1. Replace:
    • your_username - With your CData Connect AI username
    • your_pat - With your CData Connect AI Personal Access Token (PAT)
    • Your_Connection_Name - With the name of your Connect AI data source, from the Sources page
  2. Run the script.

Notebook Script 2 — Load DataFrame from Azure Data Lake Storage data:

  1. Add a new cell for this second script. From the menu on the right side of your notebook, click Add cell below.
  2. Paste the following script into the new cell:
remote_table = spark.read.format("jdbc") \
 .option("driver", "cdata.jdbc.connect.ConnectDriver") \
 .option("url", "jdbc:connect:AuthScheme=Basic;User=your_username;Password=your_pat;URL=https://cloud.cdata.com/api/;DefaultCatalog=Your_Connection_Name;") \
 .option("dbtable", "YOUR_SCHEMA.YOUR_TABLE") \
 .load()
  1. Replace:
    • your_username - With your CData Connect AI username
    • your_pat - With your CData Connect AI Personal Access Token (PAT)
    • Your_Connection_Name - With the name of your Connect AI data source, from the Sources page
    • YOUR_SCHEMA.YOUR_TABLE - With your schema and table, for example, ADLS.Resources
  2. Run the script.

Notebook Script 3 — Preview Columns:

  1. Similarly, add a new cell for this third script.
  2. Paste the following script into the new cell:
display(remote_table.select("ColumnName1", "ColumnName2"))
  1. Replace ColumnName1 and ColumnName2 with the actual columns from your Azure Data Lake Storage structure (e.g. FullPath, Permission, etc.).
  2. Run the script.
👁 Previewing Azure Data Lake Storage data data in Databricks notebook

You can now explore, join, and analyze live Azure Data Lake Storage data directly within Databricks notebooks—without needing to know the complexities of the back-end API and without replicating Azure Data Lake Storage data.


Try CData Connect AI Free for 14 Days

Ready to simplify real-time access to Azure Data Lake Storage data? Start your free 14-day trial of CData Connect AI today and experience seamless, live connectivity from Databricks to Azure Data Lake Storage.

Low code, zero infrastructure, zero replication — just seamless, secure access to your most critical data and insights.