In this blog we will discuss on how to mount Azure storage account to Databricks with SAS key. The purpose of this blog post is to mount the storage account in a shortest possible time. Here are the steps ionvolved:
- Open the storage account in the Azure Portal and then open the shared access signature key from the left panel.
- Select the duration of the SAS access key by selecting the start datetime
- Select the duration of the SAS access key by selecting end datetime. This is described in the below screensot point 2 and 3.
- Click Generate SAS and connection string. Step 4 in the screenshot.
- Copy the SAS key provided in the step 5 in the screenshot.

Now you have the SAS key for the storage account. Let’s use it in the mounting config as per the below notebook code.
val storageAccount = "put storage account name here"
val container = "Container name to mount "
val sasKey = "Copy the SAS key generated at Step 5"
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")
}
%fs ls /mnt/mymountpointname/
/*This will list all the files located at the container*/
I hope this post is useful!!