-1

I have sas url at directory level and want to use to read contents of directory instead of using connection string

pratibha
  • 1
  • 1

1 Answers1

0

Follow below Syntax:

Create mount

dbutils.fs.mount(
        source = "wasbs://<container_name>@<storage_account_name>.blob.core.windows.net/",
        mount_point = "/mnt/t123",
        extra_configs = {"fs.azure.sas.<container_name>.<storage_account_name>.blob.core.windows.net":"Your_SAS_token"})

Read csv file

file_location ="wasbs://<container_name>@<storage_account_name>.blob.core.windows.net/filename.csv"
df = spark.read.format("csv").option("inferSchema", "true").option("header", "true").option("delimiter",",").load(file_location)
 
display(df)

Ref1 Ref2

Reference:

Reading and Writing data in Azure Data Lake Storage Gen 2 with Azure Databricks by Ryan Kennedy

Mount ADLS Gen2 storage account provided by Microsoft

B. B. Naga Sai Vamsi
  • 2,386
  • 2
  • 3
  • 11