This post is how to mount on Databricks.
Notes
- Security Issue: They are shared across all clusters and users
- Should always be unmounted after use
- Due to Service Prinicpal password rotations
- Reliability esspecially in BCDR
- Databricks recommends using Unity Catalog instead of mounts as they are legacy.
- Could be conflicts in other projects due to naming
- Do not create mounts manually. Always have your project mount and unmount at the end
List Mounts
- dbutils.fs.mounts()
Unmount
- dbutils.fs.unmount("<MOUNT>")
Mount
- client_id = "<CLIENTID>"
- secret = dbutils.secrets.get(scope = "<SCOPE_NAME>", key = "<SECRET_NAME>")
- tenant_id = "<TENANT_ID>"
- storage_account_name = "<STORAGE_ACCOUNT_NAME>"
- container_name = "<CONTAINER_NAME>"
- configs = {
- "fs.azure.account.auth.type": "OAuth",
- "fs.azure.account.oauth.provider.type": "org.apache.fs.azurebfs.oauth2.ClientCredsTokenProvider",
- "fs.azure.account.oauth2.client.id": client_id,
- "fs.azure.account.oauth2.client.secret": secret,
- "fs.azure.account.oauth2.client.endpoint": "https://login.microsoftonline.com/" tenant_id + "/oauth2/token"
- }
- path = "abfss://%s@%s.dfs.core.windows.net/" % (container_name, storage_account_name)
- dbutils.fs.mount(
- source = path,
- mount_point = "/mnt/<MOUNT_NAME>",
- extra_configs = configs
- )