简体   繁体   中英

Load files to Azure file storage using python

I'm using azure file storage for data persistence of several container instances, on that side, it is working fine. I issue I have is that some of the containers read data that I load manually to the File storage via web interface. I need to update this to be able to load the files from python but I'm not finding any examples of how to to this.

There is a github repo from Azure https://github.com/Azure/azure-storage-python that is supposed to handle that, but I'm not finding any examples there, only the source code. On medium and other sites I have found tutorials for using Blob but I haven't found any for Files

As the comment said, the samples show the action for the file share. I assume that you want to read the content from the file which in the file share, the same code below:

from azure.storage.file import FileService

storageAccount='xxxxx'
accountKey='xxxxx'

file_service = FileService(account_name=storageAccount, account_key=accountKey)

# if the file in the root path of the share, please let the directory name as ''
file = file_service.get_file_to_text(share_name, directory_name, file_name)
print(file.content)

This code gets the file with type File .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM