迭代文件夹时 Azure Datalake Gen1 权限被拒绝

标签 azure azure-data-lake

我正在尝试使用 Python SDK 迭代 Azure datalake Gen1 中的所有文件夹。我正在使用分配有所有者角色的服务主体。但是,当我尝试访问某些文件夹时,出现权限被拒绝错误。我不确定我是否还需要任何其他角色,因为我猜所有者拥有最高权限。

下面是我正在使用的代码

 %pip install azure-mgmt-resource
%pip install azure-mgmt-datalake-store
%pip install azure-datalake-store


  import re
  import datetime;
  from azure.datalake.store import lib, core
  from azure.common.credentials import ServicePrincipalCredentials
  from pyspark.sql.types import StringType
  from pyspark.sql.functions import udf,split, explode,col,when,concat,array_contains,lit
  import datetime;


  def authenticate(clientId, secretId, tenantId):

      RESOURCE = 'https://datalake.azure.net/'

      tenant = tenantId

      client_id = clientId

      client_secret = secretId

      adlCreds = lib.auth(tenant_id=tenant,

                          client_secret=client_secret,

                          client_id=client_id,

                          resource=RESOURCE)

      adl = core.AzureDLFileSystem(adlCreds, store_name="xxx")

      return adl



  clientId = dbutils.secrets.get(scope = "datalakesecurity", key = "datalakeclientid")

  secretId = dbutils.secrets.get(scope = "datalakesecurity", key = "datalakecredential")

  tenantId = 'xxxxx'

  adl = authenticate(clientId, secretId, tenantId)

  path_to_look= '/'

  level1 = adl.ls(path_to_look)

  print(level1) 

最佳答案

Azure Datalake Gen1 Permission Denied while iterating over folders.

在 Azure Data Lake Gen1 中,“所有者”角色拥有对整个 Data Lake 帐户(包括所有文件夹和文件)的完全访问权限。即使您拥有所有者角色,某些文件夹级权限可能仍会阻止您访问特定文件夹。您还可以为您的服务主体授予贡献者职位。

According to this MS Document Along with the owner role you need to explicitly give the permission to read, write, execute on a folder level.

enter image description here

enter image description here

即使您的服务原则具有所有者角色,但您没有上述权限,您也会面临权限被拒绝的错误。

关于迭代文件夹时 Azure Datalake Gen1 权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76228802/

相关文章:

azure - 保护消费计划中 APIM(Azure API 管理)中的后端 API

c# - Azure Data Lake 存储文件大小限制

python - Azure 数据湖的 Pyarrow 切片下推

azure - Azure WebApps 中是否可以拥有具有不同服务计划的部署槽?

azure - 如何将第三方 oauth 服务与 Azure ACS 结合使用?

azure-functions - 使用 Azure 函数处理 Azure Datalake 存储文件

azure - 如何将数据附加到现有的Azure数据湖文件中?

azure - 如果我删除 Azure Data Lake Analytics 帐户,它会删除其默认数据源吗?

azure - Pig 无法在 HDFS 中创建(或查找)pigjobs 文件 (riskfactor.pig)

azure - 全新 Azure 订阅中的 "No quotas available"