Not able to mount azure blob storage with azure data bricks

Rupesh Kumar Mishra 0 Reputation points
2024-09-01T17:45:58.7566667+00:00

I am using below code

#Define parameters
storage_account_name = "rupeshblob001"  # e.g., "mystorageaccount"
container_name = "testcontainer"  # e.g., "mycontainer"
mount_point = "/mnt/mymountpoint"  # e.g., "/mnt/mydata"
#If using an access key
storage_account_key ="dxtmnXpJyY/A5CrERQ0Qqj/otBPh0GBBRqGYVbWhSHamxq4uLHtF1Fh3ZrKNU5RGtaItAqCPFx4w+AStIJrj3Q=="
#Mount the storage
  dbutils.fs.mount(
  source = "wasbs://{container_name}@{storage_account_name}.blob.core.windows.net",
  mount_point = "/mnt/iotdata",
  extra_configs = {"fs.azure.account.key.{storage_account_name}.blob.core.windows.net":dbutils.secrets.get(scope = "geekcoders-secret", key = "sroragekey")})

I am getting below error when run above code from azure databricks note book. I need this help urgently. any help will be appreciated. 
ExecutionError: An error occurred while calling o420.mount. : java.io.FileNotFoundException: Operation failed: "The specified filesystem does not exist.", 404, HEAD, 
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,787 questions
Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,158 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Vinod Kumar Reddy Chilupuri 155 Reputation points Microsoft Vendor
    2024-09-03T05:56:17.65+00:00

    Hi Rupesh Kumar Mishra , Welcome to Microsoft Q&A, Thank you for posting your query.

     

    Azure Databricks mounts create a link between a workspace and cloud object storage, which enables you to interact with cloud object storage using familiar file paths relative to the Databricks file system. Mounts work by creating a local alias under the /mnt directory that stores the following information:

    • Location of the cloud object storage.
    • Driver specifications to connect to the storage account or container.
    • Security credentials required to access the data.

     

    Before you can mount the container, you need to create the mount point directory in DBFS. You can do this using the dbutils.fs.mkdirs() function,

    • Azure Databricks enables users to mount cloud object storage to the Databricks File System (DBFS) to simplify data access patterns for users that are unfamiliar with cloud concepts.
    • Mounted data does not work with Unity Catalog, and Databricks recommends migrating away from using mounts and instead managing data governance with Unity Catalog.

    When you create a mount point through a cluster, cluster users 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.

    • Unmounting a mount point while jobs are running can lead to errors. Ensure that production jobs do not unmount storage as part of processing.
    • Mount points that use secrets are not automatically refreshed. If mounted storage relies on a secret that is rotated, expires, or is deleted, errors can occur, such as 401 Unauthorized. To resolve such an error, you must unmount and remount the storage.

     

    Run the following in your notebook to authenticate and create a mount point.

     configs = {"fs.azure.account.auth.type": "OAuth",

          "fs.azure.account.oauth.provider.type": "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider",
    
          "fs.azure.account.oauth2.client.id": "<application-id>",
    
          "fs.azure.account.oauth2.client.secret": dbutils.secrets.get(scope="<scope-name>",key="<service-credential-key-name>"),
    
          "fs.azure.account.oauth2.client.endpoint": "https://login.microsoftonline.com/<directory-id>/oauth2/token"}
    

    Optionally, you can add <directory-name> to the source URI of your mount point.

    dbutils.fs.mount(

    source = "abfss://<container-name>@<storage-account-name>.dfs.core.windows.net/",

    mount_point = "/mnt/<mount-name>",

    extra_configs = configs)

     

    Reference:

    Mounting cloud object storage on Azure Databricks - Azure Databricks | Microsoft Learn

     

    Mounting cloud object storage on Azure Databricks - Azure Databricks | Microsoft Learn

     

    Please let us know if you have any further queries. I’m happy to assist you further. 

     

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.