adls-service-prin-gen2(Python)
Loading...
df = spark.read.json("dbfs:/databricks-datasets/iot/iot_devices.json")
spark.conf.set("fs.azure.account.key.<storage-account-name>.dfs.core.windows.net", <storage-account-key>)
spark.conf.set("fs.azure.createRemoteFileSystemDuringInitialization", "true")
dbutils.fs.ls("abfss://<file_system>@<storage-account-name>.dfs.core.windows.net/")
spark.conf.set("fs.azure.createRemoteFileSystemDuringInitialization", "false")
dbutils.fs.ls("abfss://<file_system>@<storage-account-name>.dfs.core.windows.net/")
df.write.json("abfss://<file_system>@<storage-account-name>.dfs.core.windows.net/iot_devices.json")
df2 = spark.read.json("abfss://<file_system>@<storage-account-name>.dfs.core.windows.net/iot_devices.json")
display(df2)
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": <client-id>,
"fs.azure.account.oauth2.client.secret": <service-credential>,
"fs.azure.account.oauth2.client.endpoint": "https://login.microsoftonline.com/<directory-id>/oauth2/token"}
dbutils.fs.mount(
  source = "abfss://<file_system>@<storage-account-name>.dfs.core.windows.net/",
  mount_point = "/mnt/mymount",
  extra_configs = configs)
dbutils.fs.ls("/mnt/mymount") 
dbutils.fs.unmount("/mnt/mymount")