'Cannot mount adls gen2 in databricks using sas token
I am having issues mounting adls gen2 in databricks using sas token. I am getting this error "java.lang.NullPointerException: authEndpoint" on the "dbutils.fs.mount" line
if not any(mount.mountPoint == mountPoint for mount in dbutils.fs.mounts()):
dbutils.fs.mount(
source = f"abfss://{container_name}@{storage_account_name}.dfs.core.windows.net/",
mount_point = mountPoint,
extra_configs = {f"fs.azure.sas.{container_name}.{storage_account_name}.dfs.core.windows.net": sasKey}
)
Please how can I correctly mount adls with sas token
Solution 1:[1]
You can't mount the ADLS Filesystem using SAS key . The only way to mount the ADLS Gen 2 is using Service Principal and OAuth 2.0 .
You can access the ADLS Gen 2 Storage account using Access Key which is mentioned in this blog by Marieke Kortsmit.
A normal storage account can be mounted using SAS as shown in the below code :

val storageAccount = "Cloudshellansuman"
val container = "test"
val sasKey = "<SASToken taken from the above >"
val mountPoint = s"/mnt/mymountpointname"
try {
dbutils.fs.unmount(s"$mountPoint") // Use this to unmount as needed
} catch {
case ioe: java.rmi.RemoteException => println(s"$mountPoint already unmounted")
}
val sourceString = s"wasbs://$container@$storageAccount.blob.core.windows.net/"
val confKey = s"fs.azure.sas.$container.$storageAccount.blob.core.windows.net"
try {
dbutils.fs.mount(
source = sourceString,
mountPoint = mountPoint,
extraConfigs = Map(confKey -> sasKey)
)
}
catch {
case e: Exception =>
println(s"*** ERROR: Unable to mount $mountPoint. Run previous cells to unmount first")
}
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 | AnsumanBal-MT |
