Azure Data Lake Gen2与Databricks挂载成功后出现FileNotFoundException错误的排查求助
FileNotFoundException: / is not found After Mounting ADLS Gen2 to Databricks Let’s walk through the likely issues causing this error and how to fix them:
1. You’re using the wrong protocol for ADLS Gen2
The wasbs:// protocol is built for Azure Blob Storage (without hierarchical namespace), but ADLS Gen2 relies on the abfss:// protocol to support its filesystem-like hierarchical structure. Using wasbs:// can lead to unexpected access issues with ADLS Gen2 resources.
Update your source URL to use abfss:// with the DFS endpoint (replace .blob.core.windows.net with .dfs.core.windows.net):
source = "abfss://XXXXXXXX@YYYYYYYYYYYY.dfs.core.windows.net"
2. You’re accessing the wrong root directory
The error FileNotFoundException: / is not found indicates you’re trying to access Databricks’ local filesystem root (/), not your mounted ADLS Gen2 storage.
- Your mount point is
/mnt/, so you must reference this path explicitly when interacting with the storage. For example, use:
Instead ofdbutils.fs.ls("/mnt/")dbutils.fs.ls("/")(which points to Databricks' local root, not your mounted storage).
Pro tip: Mounting to a specific subdirectory like /mnt/adlsgen2 instead of /mnt/ helps avoid conflicts with other mounts and makes your paths clearer.
3. Verify SAS token permissions and container details
Even though your secret retrieval works, double-check these critical points:
- The SAS token has at least List and Read permissions for the target container. Without List access, you won’t be able to browse the container’s root.
- The container name (
XXXXXXXX) and storage account name (YYYYYYYYYYYY) in your source URL are spelled correctly—typos here are a common culprit.
You can test direct access to the storage (bypassing the mount) to isolate the issue:
dbutils.fs.ls( "abfss://XXXXXXXX@YYYYYYYYYYYY.dfs.core.windows.net", extraConfigs = Map("fs.azure.sas.XXXXXXXX.YYYYYYYYYYYY.dfs.core.windows.net" -> dbutils.secrets.get(scope = "SCOPENAME", key = "SCOPEKEY")) )
If this command fails, the problem lies with your SAS token or storage configuration, not the mount itself.
4. Revised mount command
Here’s a corrected version of your mount command with the proper protocol and a clearer mount point:
dbutils.fs.mount( source = "abfss://XXXXXXXX@YYYYYYYYYYYY.dfs.core.windows.net", mountPoint = "/mnt/adlsgen2", extraConfigs = Map("fs.azure.sas.XXXXXXXX.YYYYYYYYYYYY.dfs.core.windows.net" -> dbutils.secrets.get(scope = "SCOPENAME", key = "SCOPEKEY")) )
After remounting with this command, try accessing /mnt/adlsgen2 instead of /—this should resolve the FileNotFoundException.
内容的提问来源于stack exchange,提问作者mmoayed

