Access upload date of files in azure file share with a python runbook

Ana Sofia Moreira 21 Reputation points
2021-10-25T11:18:35.78+00:00

Good morning,

I want to acess the most recent files of an azure file share with a python runbook and with my code I a doubts.

1- when I list the files in the file share with this code:

    from azure.storage.file import FileService

    file_service = FileService(account_name='', account_key='')

    generator = list(file_service.list_directories_and_files(''))

    try:

        for file_or_dir in generator:

          order_file_upload={}
          file_in = file_service.get_file_properties(share_name='', directory_name="", file_name=file_or_dir.name)
          file_date= file_in.properties.last_modified
          order_file_upload[str(file_date.date())]=file_or_dir.name

    except ResourceNotFoundError as ex:

        print('ResourceNotFoundError:', ex.message)

I have this error:

Failed
Traceback (most recent call last): File "", line 17, in <module> except ResourceNotFoundError as ex:NameError: name 'ResourceNotFoundError' is not defined

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,172 questions
{count} votes