Lesson 19 – Connecting Azure Databricks to Azure Data Lake Storage Gen2 Using Unity Catalog

In the earlier lessons, many examples used small DataFrames created directly inside a Databricks notebook. In a real data engineering project, source files usually live outside Databricks in cloud storage. On Azure, a common choice is Azure Data Lake Storage Gen2 (ADLS Gen2).

This lesson explains how Azure Databricks connects to ADLS Gen2 using the current Unity Catalog approach. You will create an ADLS Gen2 storage account, create a container, create an Azure Databricks Access Connector with a managed identity, grant that identity access to storage, register the identity in Unity Catalog, create an external location, and then use a Unity Catalog volume to work with files.

🚀 Learn It in 5 Minutes

Skip the long read.
See the key concepts in one easy-to-follow infographic.

View Infographic →
💡 Important – this lesson uses the current recommended approach
DBFS Root and DBFS Mounts are legacy approaches and are deprecated for new Azure Databricks implementations. This lesson explains these concepts so you can recognize them in older projects, but the hands-on examples focus on Workspace Files for small development and testing files and Unity Catalog Volumes and External Locations for governed file-based data and cloud storage access.

Prerequisites

Before starting, make sure you have the following. Some steps require an Azure administrator or a Unity Catalog metastore administrator if your account does not have the required permissions.

  • An active Azure subscription.
  • An Azure Databricks workspace.
  • The workspace must be attached to a Unity Catalog metastore.
  • Permission to create an Azure storage account and an Access Connector, or an administrator who create them for you.
  • Permission to assign Azure RBAC roles on the ADLS Gen2 storage account.
  • Permission in Unity Catalog to create a storage credential and external location, or an administrator who can perform those steps.
  • A Databricks compute resource that can run a notebook for the final test.
💡 If you cannot see the required Unity Catalog options
Do not create a legacy mount as a workaround. Ask your Databricks administrator to confirm that the workspace is attached to a Unity Catalog metastore and that your account has the required privileges.

What Is Azure Data Lake Storage Gen2?

Azure Data Lake Storage Gen2 is Microsoft’s cloud storage service for large-scale data. It is built on Azure Blob Storage and adds a hierarchical namespace, which provides folder-like organization and file-system capabilities.

A storage account can contain one or more containers. A container is a top-level storage boundary where files and folders can be stored. For example, a container named raw might contain folders such as sales/2026/09/.

Why Does Databricks Need to Connect to ADLS Gen2?

Databricks compute is used to process data, but the data itself needs durable storage. ADLS Gen2 can store source files and other data that must remain available after a cluster or notebook session stops.

  • Databricks reads source files from cloud storage.
  • Databricks writes processed files and results to cloud storage.
  • Unity Catalog can govern who is allowed to access those storage locations.
  • Using Unity Catalog avoids putting long-lived storage secrets directly into notebooks.

Legacy Access vs. the Current Unity Catalog Approach

Older Databricks tutorials often show storage account keys, SAS tokens, service principals, Databricks secrets, dbutils.fs.mount(), and Spark configuration properties. These patterns are still useful to recognize when supporting older projects, but they are not the main approach used in this lesson.

ApproachHow access is handledUse in this lesson
Storage account keyA storage account key is supplied to the workload.Not used for the hands-on path.
SAS tokenA scoped shared token is supplied to the workload.Not used for the hands-on path.
Service principal + secretApplication identity authenticates with a client secret.Legacy/background concept.
Unity Catalog + managed identityUnity Catalog uses an Azure managed identity through an Access Connector and governs access with securable objects.Recommended hands-on approach.

Architecture Used in This Lesson

The complete flow is easier to understand when you see how the Azure and Databricks pieces connect.

💡 Simple way to remember the architecture
The Access Connector provides the Azure identity. The Storage Credential tells Unity Catalog which identity to use. The External Location connects that credential to an ADLS Gen2 path. The Volume gives users a governed place to work with files.

Below image shows the architecture how to connect ADLS gen2 with azure databricks.

Hands-On Walkthrough: Connect Azure Databricks to ADLS Gen2

Step 1: Create an ADLS Gen2 Storage Account

Start in the Azure portal. You will create the storage account that will hold the files used in this lesson.

1. Open a web browser.

Open the Azure portal https://portal.azure.com/#home

Select Sign in.

2. Search for Storage accounts.

3. Select Create.

4. Select the Azure subscription you want to use.

5. Select an existing resource group or create a new one.

6. Enter a globally unique Storage account name. For example: <storageaccountname>.

7. Choose the region you want to use.

8. On the Advanced tab, find Hierarchical namespace.

9. Set Hierarchical namespace to Enabled.

10. Review the remaining settings and select Review + create.

11. After validation succeeds, select Create.

12. Wait until deployment finishes and open the new storage account.

💡 Why Hierarchical namespace matters
Hierarchical namespace enables the file-system capabilities of ADLS Gen2. If it is not enabled, the storage account is a regular Azure Blob Storage account rather than an ADLS Gen2 account required for this lesson.

Step 2: Create a Container

The container will act as the top-level location for the lesson’s files.

  1. In the storage account, select Data storage > Containers.

2. Select + Container.

3. Enter the container name: raw.

4. Select Create.

Step 3: Create an Access Connector for Azure Databricks

The Access Connector is an Azure resource that provides a managed identity that Unity Catalog can use to access your ADLS Gen2 storage. This removes the need to put a client secret in your notebook.

1. In the Azure portal, select Create a resource.

2. Search for Access Connector for Azure Databricks.

4. Choose the Azure subscription.

5. Choose the resource group where you want the Access Connector to live.

6. Enter an Access Connector name, for example: <access-connector-name>.

7. Select the appropriate region.

8. Use the system-assigned managed identity option for this beginner exercise unless your organization requires a user-assigned identity.

Simple comparison

System-assignedUser-assigned
Who creates it?Azure creates it with the resourceYou create it separately
Identity belongs toOne Azure resourceSeparate reusable resource
Can multiple resources use it?NoYes
Deleted when resource is deleted?YesNo
ManagementSimplerMore control/reuse
Beginner setupEasierMore advanced

A system-assigned managed identity is created and managed automatically by Azure for the Access Connector. A user-assigned managed identity is created separately and can be reused by multiple Azure resources. In this lesson, we use a system-assigned managed identity because it provides a simple way for the Access Connector to authenticate to ADLS Gen2 without storing credentials or secrets.

9. Review the configuration and select Create.

10. After deployment completes, open the Access Connector.

Step 4: Grant the Access Connector Permission on ADLS Gen2

Creating the managed identity is not enough. The identity must also be allowed to read and write data in the storage account. Azure RBAC controls this permission.

1. Open your ADLS Gen2 storage account.

2. Select Access Control (IAM).

3. Select Add > Add role assignment.

  • On the role selection page, search for Storage Blob Data Contributor.

If you do not have permission to assign Azure roles, ask your Azure administrator to grant the Storage Blob Data Contributor role to the Access Connector for Azure Databricks on the storage account.

4. Select Storage Blob Data Contributor and select Next.

5. For Assign access to, select Managed identity.

6. Select + Select members.

7. Choose the subscription and select the Access Connector for Azure Databricks that you created.

10. Select Review + assign.

11. Complete the role assignment.

💡 Do not use Storage Account Contributor as the normal data-access role
Storage Blob Data Contributor is the key role for reading and writing blob data. Additional roles may be required for specific file-event scenarios. Do not grant broader permissions unless your implementation requires them.

Optional: File Events Permissions

For the simple read/write test in this lesson, Storage Blob Data Contributor is the important data-access role. If you later enable Azure Databricks file events for an external location, additional Azure permissions may be required. Microsoft documents Storage Queue Data Contributor for subscribing to file event notifications and additional permissions when Azure Databricks is expected to configure the events automatically.

💡 File Events Read / File Events setup
If your course or organization does not use file events, you do not need to add file-event permissions just to complete the basic ADLS Gen2 connection and volume test. Follow your organization’s security and ingestion requirements.

Step 5: Copy the Access Connector Resource ID

Unity Catalog needs the Access Connector resource ID when you create the storage credential.

1. Open the Access Connector resource in the Azure portal.

2. On the Overview page, locate Resource ID.

3. Copy the complete Resource ID and keep it temporarily in a safe place.

4. The value normally looks similar to the following:

/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Databricks/accessConnectors/<access-connector-name>

Step 6: Confirm Unity Catalog Is Available

Now move to your Azure Databricks workspace. The following steps require a Unity Catalog-enabled workspace.

  1. Open the Azure Databricks workspace.

2. In the left sidebar, select Catalog.

3. Confirm that Catalog Explorer opens and that you can see the catalogs available to your workspace.

4. If you do not see the required catalog or credential options, contact your Databricks administrator before continuing.

Step 7: Create a Storage Credential

A storage credential is a Unity Catalog object that represents the identity Unity Catalog uses to access cloud storage. In this lesson, the credential uses the Azure managed identity provided by the Access Connector.

1. In Catalog Explorer, select the create/add (+) option.

2. Select Create a credential.

  • For Credential type, select Azure Managed Identity.

4. Enter a storage credential name, for example: azure_adls_dev

5. Paste the Access Connector Resource ID copied in Step 5 into Access Connector ID.

6. If your organization uses a user-assigned managed identity, enter its Managed Identity ID where required.

7. Select Create.

8. Wait for validation to complete.

💡 If storage credential validation fails
Check that the Access Connector has the Storage Blob Data Contributor role on the correct storage account and that the Access Connector Resource ID was copied completely. Also confirm that you are using the correct Azure subscription, resource group, and storage account.

Step 8: Create an External Location

An external location combines a storage credential with a specific cloud storage path. In this lesson, the path points to the raw container you created earlier.

1. In Catalog Explorer, select the create/add (+) option.

2. Select Create an external location.

3. Enter an external location name, E.g azure_f1_raw_dev

4. For Storage type, select Azure.

5. For URL, enter the ADLS Gen2 container path using this format:

abfss://raw@<storage-account-name>.dfs.core.windows.net/

For Storage credential, select azure_adls_dev.

2. If your workspace shows file-event options, keep the default only if your organization has the required permissions and intends to use file events. For this basic lesson, the connection itself does not depend on file events.

3. Review the configuration.

4. Select Create.

💡 Understand the ABFSS path
The ABFSS path identifies the ADLS Gen2 storage container and, optionally, a folder within it. The pattern is:

abfss://<container>@<storage-account>.dfs.core.windows.net/<optional-folder>

Step 9: Grant Unity Catalog Permissions on the External Location

Creating an external location does not automatically give every user permission to use it. Unity Catalog permissions determine which users, groups, or service principals can use the location.

1. Open Catalog Explorer > External Locations.

2. Select azure_f1_raw_dev

3. Open the Permissions tab.

4. Select Grant.

5. Choose your user or the appropriate data-engineering group.

6. For a simple read/write file exercise, grant READ FILES and WRITE FILES as required by your organization’s access policy.

7. Remember that WRITE FILES requires READ FILES as well.

8. Select Grant.

💡 Principle of least privilege
Grant only the permissions required for the task. In a shared environment, use groups instead of granting broad access to individual users wherever your organization’s access model supports it.

Step 10: Create a Catalog and Schema for the Exercise

The external location protects the underlying cloud path. A Unity Catalog volume must live inside a catalog and schema. If your organization already provides a catalog and schema for labs, use those instead of creating new ones.

  1. In Catalog Explorer, select Create catalog.
  • Create a catalog named: test_catalog.

If you are using a Serverless workspace, do not select “Use default storage.” Instead, select the external location created for this environment and specify the required storage path. Since you are using a Serverless workspace, leave Use default storage unchecked and select the required external location.
Leave the Subpath field blank if you want to use the root path of the selected external location.

  • Open the new catalog and select Create schema.

4. Create a schema named: raw.

5. Make sure you have USE CATALOG and USE SCHEMA permissions for the objects you will use.

Step 11: Create an External Volume

Databricks recommends Unity Catalog volumes for managing non-tabular files in cloud object storage. An external volume is registered against a directory inside an external location.

1. Open test_catalog > raw.

2. Select Create > Volume.

3. Choose External volume.

4. Enter the volume name: raw_files.

5. For the location, use a subdirectory inside the external location. For example:

abfss://raw@<storage-account-name>.dfs.core.windows.net/raw_files/

A Managed volume stores files in storage managed by Unity Catalog, while an External volume uses a storage location that we have already configured in ADLS Gen2. We select External volume because the files for this lesson are stored in our existing ADLS Gen2 external location. This allows Unity Catalog to govern access to files stored in that external storage location.

1. Select Create.

2. Open the newly created volume and confirm that its path is displayed.

💡 Why use a subdirectory?
Keep external volumes and tables in separate subdirectories instead of placing multiple objects at the root of the same external location. This reduces path conflicts and makes the storage layout easier to understand.

Step 12: Access a File Stored in ADLS Gen2

  1. Create sampletest.csv locally.
  2. Upload sampletest.csv to the ADLS Gen2 folder used by your External Volume.
  3. In Databricks, open the Unity Catalog External Volume.
  4. Verify that sampletest.csv is visible.

Read the file from Databricks.

For example:

df = spark.read.option("header", "true").csv(

    "/Volumes/test_catalog/raw/raw_files/sampletest.csv"

)

display(df)

The file lives in ADLS Gen2. Unity Catalog governs access to that storage, and Databricks reads the file through the External Volume.

Note: Step 13 demonstrates another way of working with the External Volume by uploading a test file

through Databricks. Because the External Volume points to an ADLS Gen2 location, the uploaded file is

stored in the underlying ADLS Gen2 storage. You can then verify the file from both Databricks and

Azure Storage.

Then Steps 14–15 can demonstrate write and read-back.

Step 13: Upload a Test File to the Volume

You will upload a small CSV file to the Unity Catalog external volume. The volume points to your ADLS

Gen2 storage location, so the file is ultimately stored in ADLS Gen2.

You are uploading the file through the Unity Catalog volume, not directly through the Azure Storage

portal. Because this is an External Volume, the file is physically stored in the underlying ADLS Gen2

location configured for the volume. External volumes provide Unity Catalog governance over existing

cloud-storage directories.

1. Create a small local CSV file named sampletest.csv with a few rows, for example columns id and name.

2. In the Databricks workspace, select New > Add or upload data.

3. Select Upload files to a volume.

4. Choose test_catalog > raw > raw_files as the destination.

5. Select your sample_test.csv file.

6. Wait for the upload to complete.

7. Open the volume and confirm that the file is visible.

Step 13: Read the File from a Databricks Notebook

Now create a notebook and read the file using the Unity Catalog volume path. Notice that there is no client secret, Spark OAuth configuration, or storage-account key in the notebook.

  1. Create or open a Databricks notebook.

2. Attach the notebook to an available compute resource.

3. Use the following code and replace the placeholders with your catalog, schema, volume, and file name.

file_path = "/Volumes/lesson19_catalog/raw/lesson19_files/lesson19_test.csv"

df = (
    spark.read
    .option("header", "true")
    .option("inferSchema", "true")
    .csv(file_path)
)

display(df)

Run the cell. The rows from the CSV file should be displayed.

Step 14: Write a Test File to the Volume

To confirm write access as well as read access, create a small DataFrame and write it to another folder in the volume.

test_df = spark.range(10).withColumnRenamed("id", "name")

output_path = "/Volumes/test_catalog/raw/lesson19_files/test_output"

(
    test_df.write
    .mode("overwrite")
    .option("header", "true")
    .csv(output_path)
)

print("Test file written successfully.")

1. Run the cell.

2. Open the raw_files volume in Catalog Explorer.

3. Confirm that the test_output directory was created.

4. If the write fails with PERMISSION_DENIED, return to Step 9 and verify WRITE FILES and READ FILES permissions.

Step 15: Read the Written Data Back

read_back_df = (
    spark.read
    .option("header", "true")
    .csv("/Volumes/test_catalog/raw/raw_files/test_output")
)

display(read_back_df)

Finally, read the data that you just wrote. This verifies the complete read/write path.

What Happened Behind the Scenes?

1. The notebook requested access to a file under a Unity Catalog volume.

2. Unity Catalog checked the user’s permissions on the catalog, schema, and volume.

3. The volume is registered against a governed external storage location.

4. The external location uses a storage credential.

5. The storage credential uses the Azure managed identity provided by the Access Connector.

6. Azure RBAC allows that managed identity to access the ADLS Gen2 storage.

7. The file was therefore read or written without placing an Azure storage secret in the notebook.

Troubleshooting Common Errors

ProblemWhat to check
Storage credential validation failsConfirm the Access Connector Resource ID and verify Storage Blob Data Contributor on the correct storage account.
External location cannot be createdConfirm Unity Catalog is enabled and that your account has CREATE EXTERNAL LOCATION on the metastore and storage credential.
PERMISSION_DENIED when readingCheck READ FILES or the appropriate volume READ VOLUME permission and confirm USE CATALOG / USE SCHEMA.
PERMISSION_DENIED when writingCheck WRITE FILES plus READ FILES on an external location, or WRITE VOLUME on a volume.
External volume cannot be createdConfirm the target path is inside an external location and that you have CREATE EXTERNAL VOLUME.
Path does not existCheck the catalog, schema, volume name, and file path. Volume paths use /Volumes/<catalog>/<schema>/<volume>/…
File-event warning appearsFor this basic read/write exercise, file events are not the same thing as basic storage access. If file events are required, configure the additional Azure permissions documented by Databricks.
No Catalog / Credentials optionsAsk the workspace administrator to confirm Unity Catalog/metastore configuration and your privileges.

Legacy Pattern You May Still See

You may encounter older code such as dbutils.fs.mount(), Databricks secret scopes containing storage credentials, or Spark configuration properties for OAuth authentication. Do not assume that code is wrong simply because it is old, it may belong to a legacy project. The important point is that a new Unity Catalog-enabled implementation should normally be designed around Unity Catalog governance rather than adding new legacy mounts.

# Legacy-style example you may encounter in older projects
# This is intentionally shown only for recognition.
# Do not use it as the main implementation for this lesson.
dbutils.fs.mount(
    source="wasbs://<container>@<storage-account>.blob.core.windows.net/",
    mount_point="/mnt/<name>",
    extra_configs={...}
)
💡 Do not copy the legacy example into your hands-on exercise
The legacy example is provided for recognition and reference only. Do not copy the legacy configuration into your hands-on exercise. The hands-on steps above use the current Unity Catalog approach with an Access Connector, managed identity, external location, and volume.

Conclusion

Connecting Azure Databricks to ADLS Gen2 is a foundational step for real-world data engineering. The important idea is not just that Databricks can reach a storage account, but that the access should be governed and manageable.

In this lesson, you created an ADLS Gen2 storage account, created a container, created an Access Connector with a managed identity, granted Azure RBAC access, created a Unity Catalog storage credential and external location, created an external volume, and verified file read/write operations from a notebook.

The older direct-credential approach is useful background knowledge because you will still see it in existing projects. For new Unity Catalog-enabled Azure Databricks implementations, the current direction is centralized governance through Unity Catalog and managed identities.

Tags Connecting Azure Databricks to Azure Data Lake Storage Gen2 Using Unity Catalog
Databricks Link
Microsoft Link

Test Your Knowledge

Quiz