通过 Azure 数据砖中使用 Credential passthrough 的 python 脚本,查找 Azure Datalake 中文件夹的最后修改时间戳。

问题描述 投票:0回答:1

我有一个 Azure DataLake 存储 Gen2,其中包含一些 Parquet 文件。我的组织已经启用了凭证直通,因此我能够在 Azure Databricks 中创建一个 python 脚本,并使用 dbutils.fs.ls 访问 ADLS 中的可用文件。所有这些都能正常工作。

现在,我也需要访问这些文件的最后修改时间戳。我发现了一个 联系 可以做到这一点。然而,它使用BlockBlobService,并且需要一个账户密钥。

我没有账户密钥,而且由于组织的安全政策,我也无法获得一个账户密钥。我不知道如何使用Credential passthrough做同样的事情。这里有什么想法吗?

pyspark azure-data-lake azure-blob-storage azure-databricks
1个回答
0
投票

您可以尝试使用凭证直通挂载 Azure DataLake Storage Gen2 实例。

    configs = {
      "fs.azure.account.auth.type": "CustomAccessToken",
      "fs.azure.account.custom.token.provider.class":   spark.conf.get("spark.databricks.passthrough.adls.gen2.tokenProviderClassName")
    }
    mount_name = 'localmountname'
    container_name = 'containername'
    storage_account_name = 'datalakestoragename'
    dbutils.fs.mount(
      source = f"abfss://{container_name}@{storage_account_name}.dfs.core.windows.net/",
      mount_point = f"/mnt/{mount_name}>",
      extra_configs = configs)
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.