使用 python 将文件加载到 Azure 文件存储

Load files to Azure file storage using python

我正在使用 azure 文件存储来实现多个容器实例的数据持久性,在这方面,它工作正常。我遇到的问题是,一些容器读取我通过 Web 界面手动加载到文件存储的数据。我需要更新它才能从 python 加载文件,但我没有找到任何关于如何做到这一点的示例。

有一个来自 Azure https://github.com/Azure/azure-storage-python 的 github 存储库应该可以处理这个问题,但我在那里找不到任何示例,只有源代码。在 medium 和其他网站上,我找到了使用 Blob 的教程,但我没有找到任何文件

如评论所述,samples 显示文件共享的操作。我假设你想从文件共享中的文件中读取内容,下面是相同的代码:

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)

此代码获取类型为 File 的文件。