'Mount ADLS Gen2 Storage - File must be dbfs or s3n: /

I want to mount ADLS Gen2 Storage in Databricks with this code:

%python

configs = {
  "fs.azure.account.key.<storage-account-name>.dfs.core.windows.net": <storage-account-key>,
  "spark.hadoop.fs.azure.account.key.<storage-account-name>.dfs.core.windows.net": <storage-account-key>
}

dbutils.fs.mount(
  source = "abfss://<container-name>@<storage-account-name>>.dfs.core.windows.net/",
  mount_point = "/mnt/aaa",
  extra_configs = configs)

But I get:

enter image description here

enter image description here

Any idea what can be root cause?



Solution 1:[1]

Mount ADLS Gen2 Storage in Databrick

There are two scenarios you can Mount and implement ADLS Gen2 Storage in Databrick.

Scenario 1:

Directly take the Access key from ADLS Gen2 Blob Storage past in <storage-account-Access key> of extra_configs as shown in the create mount.

Syntax

spark.conf.set("fs.azure.account.key.<storage-account-name>.dfs.core.windows.net", dbutils.secrets.get(scope="<Scope-Name>",key="Key_Value"))

Ref1

Create Mount

dbutils.fs.mount(
    source = "wasbs://<container-name>@<storage-account-name>.blob.core.windows.net/",
    mount_point = "/mnt/io243",
    extra_configs = {"fs.azure.account.key.<storage-account-name>.blob.core.windows.net":"<storage-account-Access key>"})

Ref2

Scenario 2:

Go to the Access Keys and copy the key -> Create Secret for Access Key in Azure Key Vault .

Ref3

Create an Azure Key Vault and Secret Scope -> Create Scope -> Enter the DNS Name (for Example, https://databrickskv.vault.azure.net/) and Resource ID -> Go to Properties tab of an Azure Key Vault in your Azure portal you get both DNS and Resource ID.

Ref4

dbutils.fs.mount(
            source = "wasbs://<container-name>@<storage-account-name>.blob.core.windows.net/",
            mount_point = "/mnt/io243",
            extra_configs = {"fs.azure.account.key.<storage-account-name>.blob.core.windows.net":"dbutils.secrets.get(scope = "databricks-secret-scope", key = "blob-container-key")}

Ref5

Reference:

https://bigdataprogrammers.com/create-mount-point-in-azure-databricks/

https://docs.microsoft.com/en-us/azure/databricks/data/databricks-file-system

https://www.youtube.com/watch?v=yeNgrBxHmCc

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1