Accessing Azure Data Lake from Databricks

πŸ” How to Access Azure Data Lake from Databricks: A Complete Overview with Real-World Examples

Accessing Azure Data Lake Gen2 (ADLS Gen2) from Azure Databricks is a critical component of modern data engineering and analytics workflows. Depending on your security needs and use cases, there are multiple authentication methods available β€” each offering different levels of control, flexibility, and governance.

In this article, we’ll break down each method using visual representations and explain how and when to use them with examples.


πŸ“ 1. Access via Access Keys, SAS Tokens, or Service Principals

This is the most basic method and is often used for development or one-off scripts.

πŸ”‘ Storage Access Key

spark.conf.set("fs.azure.account.key.<storage_account>.dfs.core.windows.net", "<access_key>")

πŸ” Shared Access Signature (SAS Token)

spark.conf.set("fs.azure.sas.<container>.<storage_account>.dfs.core.windows.net", "<sas_token>")

πŸ‘€ Service Principal Authentication

spark.conf.set("fs.azure.account.auth.type", "OAuth")
spark.conf.set("fs.azure.account.oauth.provider.type", "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider")
spark.conf.set("fs.azure.account.oauth2.client.id", "<client_id>")
spark.conf.set("fs.azure.account.oauth2.client.secret", "<client_secret>")
spark.conf.set("fs.azure.account.oauth2.client.endpoint", "https://login.microsoftonline.com/<tenant_id>/oauth2/token")

πŸ“Œ Use case: Automation scripts, service-to-service authentication, or pipelines in dev/test environments.


πŸ§ͺ 2. Session Scoped Authentication

With this method, the credentials apply only to the current notebook session. This allows user-specific access and better isolation.

spark.conf.set("fs.azure.account.oauth2.client.secret", dbutils.secrets.get(scope="my-scope", key="sp-secret"))

πŸ“Œ Use case: Interactive notebooks, experimentation, and personal access sessions with secure secrets.


🧱 3. Cluster Scoped Authentication

Here, the credentials are set at the cluster level, making them available to all notebooks running on that cluster.

πŸ”§ Add the following under cluster > Spark Config:

spark.hadoop.fs.azure.account.auth.type OAuth
spark.hadoop.fs.azure.account.oauth.provider.type org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider
spark.hadoop.fs.azure.account.oauth2.client.id <client_id>
spark.hadoop.fs.azure.account.oauth2.client.secret <client_secret>
spark.hadoop.fs.azure.account.oauth2.client.endpoint https://login.microsoftonline.com/<tenant_id>/oauth2/token

πŸ“Œ Use case: Shared jobs and collaborative environments where multiple users need the same access level.


πŸ‘₯ 4. Azure Active Directory (AAD) Passthrough Authentication

AAD Passthrough allows users to authenticate to ADLS Gen2 using their individual Azure AD identity, ensuring fine-grained access control.

πŸ”§ To enable:

  • Use a Premium Tier Databricks workspace
  • Enable Credential Passthrough in cluster settings
  • Ensure RBAC/ACL permissions are set on the storage account

πŸ“Œ Use case: Enterprises with strict identity-based access control and audit requirements.


🧩 5. Unity Catalog Integration

Unity Catalog offers centralized governance for all data assets. It enhances security and data management with features like:

  • Row and column-level access control
  • Built-in data lineage
  • Central metadata management
  • Access control via Azure AD groups

πŸ“Œ Use case: Enterprise-wide data platforms that need centralized access control across teams and workspaces.

-- Example SQL command
GRANT SELECT ON CATALOG marketing_data TO `data-analysts`

πŸ“‹ 6. Summary of Access Methods

Access MethodScopeSecurity LevelIdeal For
Access KeysAccount-wideπŸ”“ LowDev/test environments
SAS TokensTime-limited⚠️ MediumTemporary access scenarios
Service PrincipalApp/ClusterπŸ” HighAutomated jobs and production pipelines
Session Scoped AuthNotebook sessionπŸ” HighIsolated, secure, and temporary notebook runs
Cluster Scoped AuthShared clustersπŸ” MediumShared access across a team
AAD PassthroughUser-basedπŸ” Very HighFine-grained, identity-based access
Unity CatalogPlatform-wideπŸ” Very HighEnterprise data governance and access control

βœ… Recommended Approach for Enterprise Projects

For production-grade solutions:

  • Use Unity Catalog if you require centralized access control.
  • Use AAD Passthrough if you need user-specific access enforcement.
  • Use Service Principal with secrets or Key Vaults for automation and pipelines.
  • Avoid using access keys or SAS tokens in production unless temporarily required.

πŸ“Ž Final Notes

Azure Databricks supports multiple flexible and secure ways to access Azure Data Lake Gen2. The right approach depends on your environment, data governance needs, and the scale of your organization.

As a best practice, always:

  • Use Azure Key Vault or Databricks Secrets to store sensitive credentials.
  • Prefer AAD and Unity Catalog in enterprise-grade architectures.
  • Apply RBAC and ACLs at the storage level to reinforce security.

Related Posts

Z-ORDER in Databricks: Magic or Myth?

When it helps, when it hurts, how to pick columns, and what KPIs to measure. Introduction: Why the Hype Around Z-ORDER? If you’ve spent time in Databricks,…

Read More

Taming Small Files in Delta Lake

Optimal file sizes, compaction strategies, and how to keep your Delta tables lightning-fast Why Small Files Are a Big Problem Delta Lake is powerful, but it inherits…

Read More

Databrick Serverless compute plane networking

Here’s a simple line-by-line summary of the Serverless compute plane networking (08/04/2025): General idea Serverless egress control (outbound connections) Network Connectivity Configuration (NCC) What NCC enables: Extra…

Read More

Databrick Serverless compute limitations

Here’s a simple, line-by-line summary of the Serverless compute limitations (09/29/2025): General limitations Streaming limitations Machine learning limitations Notebook limitations Job limitations Compute-specific limitations Caching limitations Hive…

Read More

Best practices for Databrick serverless compute

Best practices for serverless compute Big picture Before you migrate Ingesting data (getting data in) Querying external data (without moving it) Spark configurations Watch your costs Quick…

Read More

Databrick Serverless compute release

Here’s a simple line-by-line summary of the important points from the Serverless Compute release notes (09/24/2025): Perfect πŸ‘ Here’s a one-page cheat sheet table for the Serverless…

Read More
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x