无法在Databricks上使用python访问已装载的卷

我试图通过使用凭据传递将访问Azure存储帐户Gen2容器的权限授予其Databricks工作区中的团队,方法是将其安装到dbfs。我希望能够使用active Directory管理访问,因为最终会有容器以只读方式安装。

我的代码基于本教程:https://docs.microsoft.com/en-us/azure/databricks/data/data-sources/azure/adls-passthrough#adls-aad-credentials

从我的conf中提取:

"spark_conf": {
        "spark.databricks.cluster.profile": "serverless","spark.databricks.passthrough.enabled": "true","spark.databricks.delta.preview.enabled": "true","spark.databricks.pyspark.enableProcessIsolation": "true","spark.databricks.repl.allowedLanguages": "python,sql"
    }

然后我运行以下代码:

dbutils.fs.mount(
  source = f"wasbs://data@storage_account_name.blob.core.windows.net",mount_point = "/mnt/data/",extra_configs = {
  "fs.azure.account.auth.type":"CustomaccessToken","fs.azure.account.custom.token.provider.class":spark.conf.get("spark.databricks.passthrough.adls.gen2.tokenProviderClassname")
}

这是成功的,因为我可以使用dbutils访问该卷。

>> dbutils.fs.ls('dbfs:/mnt/storage_account_name/data')
[FileInfo(path='dbfs:/mnt/storage_account_name/data/folder/',name='folder/',size=0)]

我的问题是我运行%sh ls /dbfs/mnt/storage_account_name/data或尝试使用python进行访问

>> import os 
>> os.listdir('/dbfs/')
Out[1]: []

>> os.listdir('/dbfs/mnt/')
FileNotFoundError: [Errno 2] No such file or directory: '/dbfs/mnt/'

我找不到我想念的东西。是否有一些配置可以使其可被python访问? 谢谢。

felixwoo80 回答:无法在Databricks上使用python访问已装载的卷

使用凭据传递选项时有某些限制,这就是为什么它不起作用的原因。没有语法问题。请参阅此offical doc进行了解。

,

答案很简单。

本地文件API限制

以下列表列举了本地文件API使用方面的限制 适用于每个Databricks运行时版本。

All - Does not support credential passthrough.

来源:https://docs.microsoft.com/en-us/azure/databricks/data/databricks-file-system#local-file-apis

本文链接:https://www.f2er.com/2772496.html

大家都在问