pythonazureazure-storageazure-files

How to download entire directory from azure file share


Not able to download entire directory from azure file share in python

I have used all basic stuffs available in google

share = ShareClient.from_connection_string(connection_string, "filshare")
my_file = share.get_file_client("dir1/sub_idr1")
# print(dir(my_file))
stream_1 = my_file.download_file()

Solution

  • I tried in my environment and got below results:

    Initially I tried with python,

    Also you check Azure Portal > Select your Storage account > File Share and Directory > There's no option in Portal too to download the directory, but there's an option to download specific file.

    As workaround, if you need to download directory from file-share, you can use Az copy tool command to download the directory in your local machine.

    I tried to download the Directory with Az-copy command and was able to download to it successfully!

    Command:

    azcopy copy 'https://mystorageaccount.file.core.windows.net/myfileshare/myFileShareDirectory?sv=2018-03-28&ss=bjqt&srs=sco&sp=rjklhjup&se=2019-05-10T04:37:48Z&st=2019-05-09T20:37:48Z&spr=https&sig=/SOVEFfsKDqRry4bk3xxxxxxxx' 'C:\myDirectory' --recursive --preserve-smb-permissions=true --preserve-smb-info=true
    

    Console:

    enter image description here

    Local environment: enter image description here