Search code examples
pythonpermissionsazure-active-directoryazure-data-lakeazure-files

Python PermissionError accessing Azure Datalake folder


I'm trying to upload files from a shared folder to an Azure Datalake gen 1 folder.

For now, i am just testing the connection, and listing folders under the root directory:

adlCreds = lib.auth(tenant_id = tenant_id, client_secret = client_secret, client_id = client_id, resource = RESOURCE, azure_username = azure_username,azure_password=azure_password)

adls = core.AzureDLFileSystem(adlCreds, store_name=adlsAccountName)

print(adls.ls())

That works fine and i can see all folders.

But when i am trying to access one of those folders with the ls method or the walk method, i am getting this error:

Traceback (most recent call last):
  File "C:\Users\Python37-32\test_azure.py", line 46, in <module>
    print(adls.ls('/Test'))
  File "C:\Users\Python37-32\lib\site-packages\azure\datalake\store\core.py", line 164, in ls
    files = self._ls(path, invalidate_cache)
  File "C:\Users\Python37-32\lib\site-packages\azure\datalake\store\core.py", line 143, in _ls
    self.dirs[key] = self._ls_batched(key, batch_size=batch_size)
  File "C:\Users\Python37-32\lib\site-packages\azure\datalake\store\core.py", line 124, in _ls_batched
    ls_call_result = self.azure.call('LISTSTATUS', path, **parms)
  File "C:\Users\Python37-32\lib\site-packages\azure\datalake\store\lib.py", line 437, in call
    self.log_response_and_raise(response, PermissionError(path), level=exception_log_level)
  File "C:\Users\Python37-32\lib\site-packages\azure\datalake\store\lib.py", line 345, in log_response_and_raise
    raise exception
PermissionError: Test

I am granted by Read, Write and Execute privileges on the root and the 'Test' folder.

Do you have an idea why the permission is denied ?

Thank you for your time.


Solution

  • Add my comment as an answer:

    The error was caused by you just granted the permission on the root(add to This folder without all children), you also need to grant the permission for all children, then it will work.