Azure Blob storage

Azure Blob storage is a service for storing large amounts of unstructured object data, such as text or binary data. You can use Blob storage to expose data publicly to the world, or to store application data privately. Common uses of Blob storage include:

  • Serving images or documents directly to a browser
  • Storing files for distributed access
  • Streaming video and audio
  • Storing data for backup and restore, disaster recovery, and archiving
  • Storing data for analysis by an on-premises or Azure-hosted service

This article explains how to access Azure Blob storage by mounting storage using DBFS or directly using APIs.


You can read data from public storage accounts without any additional settings. To read data from a private storage account, you must configure a Shared Key or a Shared Access Signature (SAS). For leveraging credentials safely in Databricks, we recommend that you follow the Secret management user guide as shown in Mount an Azure Blob storage container.

Mount Azure Blob storage containers to DBFS

You can mount a Blob storage container or a folder inside a container to Databricks File System (DBFS). The mount is a pointer to a Blob storage container, so the data is never synced locally.


  • Azure Blob storage supports three blob types: block, append, and page. You can only mount block blobs to DBFS.
  • All users have read and write access to the objects in Blob storage containers mounted to DBFS.
  • Once a mount point is created through a cluster, users of that cluster can immediately access the mount point. To use the mount point in another running cluster, you must run dbutils.fs.refreshMounts() on that running cluster to make the newly created mount point available for use.

DBFS uses the credential that you provide when you create the mount point to access the mounted Blob storage container. If a Blob storage container is mounted using a storage account access key, DBFS uses temporary SAS tokens derived from the storage account key when it accesses this mount point.

Mount an Azure Blob storage container

  1. To mount a Blob storage container or a folder inside a container, use the following command:

      source = "wasbs://<container-name>@<storage-account-name>",
      mount_point = "/mnt/<mount-name>",
      extra_configs = {"<conf-key>":dbutils.secrets.get(scope = "<scope-name>", key = "<key-name>")})
      source = "wasbs://<container-name>@<storage-account-name><directory-name>",
      mountPoint = "/mnt/<mount-name>",
      extraConfigs = Map("<conf-key>" -> dbutils.secrets.get(scope = "<scope-name>", key = "<key-name>")))


    • <mount-name> is a DBFS path representing where the Blob storage container or a folder inside the container (specified in source) will be mounted in DBFS.
    • <conf-key> can be either<storage-account-name> or<container-name>.<storage-account-name>
    • dbutils.secrets.get(scope = "<scope-name>", key = "<key-name>") gets the key that has been stored as a secret in a secret scope.
  2. Access files in your container as if they were local files, for example:

    # python
    df ="/mnt/<mount-name>/...")
    df ="dbfs:/<mount-name>/...")
    // scala
    val df ="/mnt/<mount-name>/...")
    val df ="dbfs:/<mount-name>/...")

Unmount a mount point

To unmount a mount point, use the following command:


Access Azure Blob storage directly

This section explains how to access Azure Blob storage using Spark DataFrame and RDD APIs.

Access Azure Blob storage using the DataFrame API

You can read data from Azure Blob storage using the Spark API and Databricks APIs:

  • Set up an account access key:

  • Set up a SAS for a container:


Once an account access key or a SAS is set up in your notebook, you can use standard Spark and Databricks APIs to read from the storage account:

val df ="wasbs://<container-name>@<storage-account-name><directory-name>")"wasbs://<container-name>@<storage-account-name><directory-name>")

Access Azure Blob storage using the RDD API

Hadoop configuration options set using spark.conf.set(...) are not accessible via SparkContext. This means that while they are visible to the DataFrame and Dataset API, they are not visible to the RDD API. If you are using the RDD API to read from Azure Blob storage, you must set the credentials using one of the following methods:

  • Specify the Hadoop credential configuration options as Spark options when you create the cluster. You must add the spark.hadoop. prefix to the corresponding Hadoop configuration keys to tell Spark to propagate them to the Hadoop configurations that are used for your RDD jobs:

    # Using an account access key<storage-account-name> <storage-account-access-key>
    # Using a SAS token<container-name>.<storage-account-name> <complete-query-string-of-sas-for-the-container>
  • Scala users can set the credentials in spark.sparkContext.hadoopConfiguration:

    // Using an account access key
    // Using a SAS token


These credentials are available to all users who access the cluster.