Search code examples
databricksazure-databricksazure-data-lake

Error when trying to mount a directory on Azure Data Lake from Azure Databricks


There are many people having problems with Mounting an Azure DataLake Container, and this problem can have multiple root causes.

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": "client_id", "fs.azure.account.oauth2.client.secret": "secret_value", "fs.azure.account.oauth2.client.endpoint": "https://login.microsoftonline.com/tenant_id/oauth2/token"}

dbutils.fs.mount( source = f"abfss://aggregated@{account_name}.dfs.core.windows.net/", mount_point = "/mnt/aggregated", extra_configs = configs)

Please be aware of the error message.

ExecutionError: An error occurred while calling o487.mount. : Operation failed: "This request is not authorized to perform this operation.", 403, HEAD, https://<account_name>.dfs.core.windows.net/aggregated/?upn=false&action=getAccessControl&timeout=90 at shaded.databricks.azurebfs.org.apache.hadoop.fs.azurebfs.services.AbfsRestOperation.execute(AbfsRestOperation.java:246) at shaded.databricks.azurebfs.org.apache.hadoop.fs.azurebfs.services.AbfsClient.getAclStatus(AbfsClient.java:955) at shaded.databricks.azurebfs.org.apache.hadoop.fs.azurebfs.services.AbfsClient.getAclStatus(AbfsClient.java:937) at shaded.databricks.azurebfs.org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.getFileStatus(AzureBlobFileSystemStore.java:893)


Solution

  • Many people recommended solutions. One of the preconditions is to add service principals as described here: https://learn.microsoft.com/en-us/azure/databricks/data/data-sources/azure/adls-gen2/#--mount-an-azure-data-lake-storage-gen2-account-using-a-service-principal-and-oauth-20

    if your storage account has not have the service principal associated, it will not work. Many answers in this kind of situations tell you to check your rights and user configuration as you have a getAclStatus() method in your stack trace.

    In my case, the error message on AbfsRestOperation.execute(AbfsRestOperation.java:246) pointed out that it was an issue with the firewall. Once I opened traffic for all public networks, it worked.