How to create a mount point to File share in Azure Storage account

RajaDOP
New Contributor

Hello All,

I have a requirement to create a mount point to file share in Azure Storage account, I did follow the official documentation. However, I could not create the mount point to fileshare.. and the documentation discribed the mount point creation to only containers in Azure storage account.. that did not work for fileshare.

Documentation I followed and it explained only for container mounting: Access Azure Blob Storage using Azure Databricks and Azure Key Vault | Microsoft Learn

Command I used:
---------------------------------------

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

df = spark.read.text("/mnt/<mount-name>/<file-name>")

df.show()

------------

Can somoone please share the step-by-spey process to create mount point to Fileshare in Azure Storage account from Databricks only.

Appreciate your help.!!

Raja

Aaaddison
New Contributor II

Hi Raja,

You're correct that the wasbs:// method is for Azure Blob Storage, not File Shares! I believe File Share mounting is different and would require you to use SMB protocol mounted outside of Databricks since File Shares isn't natively supported! So you can either use a VM or container, or instead of mounting, use the Azure SDK for Python to read/write files directly from Azure File Share: 

1. install SDK: pip install azure-storage-file-share

2.read the file you want from Azure File Share w/Python in Databricks (sample code):

from azure.storage.fileshare import ShareFileClient

file_client = ShareFileClient.from_connection_string(
  conn_str="<your-connection-string>",
  share_name="<share-name>",
  file_path="<file-name>"
)

download = file_client.download_file()
file_content = download.readall()
print(file_content.decode())

How to get Connection-String for File Share?