Search code examples
python-3.xazure-devopsazure-filesazure-runbook

Connect azure runbook with file share in azure with python


I have azure automation runbook script that I want to connect to a file share in azure. I can't acess the file share with the runbook, I tried the code bellow, but it didn't work.

conn_str = ''
blob_service_client = BlobServiceClient.from_connection_string(conn_str)

blob_list = blob_service_client.get_container_client('').list_blobs()

for blob in blob_list:
    print(blob.name)

How can I get acess of the files in the file share, with a runbook in python?


Solution

  • I manage to achieve what I wanted with the help of this link: https://learn.microsoft.com/en-us/azure/storage/files/storage-python-how-to-use-file-storage?tabs=python#enumerate-files-and-directories-in-an-azure-file-share

    And I used this example code:

    file_service = FileService(account_name='', account_key='')
    generator = file_service.list_directories_and_files('')
    for file_or_dir in generator:
        print(file_or_dir.name)