You are on page 1of 2

ADLS to databricks connectivity

How to connect Adlsgen2 to databricks

1.Create data lake gen2 account

2.create key valut to store secerts

3.create an web application through app registrastion

Application id:

Object ID:

Directory (tenant) ID:

4.in app registration itself navigate to certificates and secreats

create an new client

screat

value:

5.store secreat key in keyvault (which is generated in app registration)

6..past below code in adb notbook

configs = {"fs.azure.account.auth.type": "OAuth",

"fs.azure.account.oauth.provider.type":
"org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider",

"fs.azure.account.oauth2.client.id": "<application-id>",

"fs.azure.account.oauth2.client.secret": dbutils.secrets.get(scope="<scope-
name>",key="<service-credential-key-name>"),

"fs.azure.account.oauth2.client.endpoint":
"https://login.microsoftonline.com/<directory-id>/oauth2/token"}

# Optionally, you can add <directory-name> to the source URI of your mount point.

dbutils.fs.mount(

source = "abfss://<container-name>@<storage-account-name>.dfs.core.windows.net/",

mount_point = "/mnt/<mount-name>",

extra_configs = configs)

7.create screate scope in databricks

https://adb-8814657146917349.9.azuredatabricks.net/?o=349#secrets/createScope

scopename:

dns:go keyvalut from properties take url

8.Give permission to registed app to access adls2


df=spark.read.format("csv").option("inferSchema",True).option("header",True).load("dbfs:/mnt/
acroadls/annual-enterprise-survey-2020-financial-year-provisional-size-bands-csv.csv")

You might also like