我正在尝试在本地使用 python 将 csv/pdf 文件上传到 azure blob 存储。
我关注了这篇文章,但这会引发错误,
from azure.storage.blob import BlockBlobService
from azure.storage.blob import ContentSettings
block_blob_service = BlockBlobService(account_name='account_name', account_key='key1')
block_blob_service.create_container('cn1')
block_blob_service.set_container_acl('cn1', public_access=PublicAccess.Container)
#Upload the CSV file to Azure cloud
block_blob_service.create_blob_from_path(
'mycontainer',
'C:/uploads/blob.csv',
'C:/uploads/blob.pdf',
content_settings=ContentSettings(content_type='application/CSV')
)
上传后我想使用上传的文件来处理。
回溯(最近一次通话最后):
文件“”,第 1 行,在 block_blob_service.create_container('cn1')
文件“c:\users\rb287jd\appdata\local\programs\python\python36\lib\site-packages\azure\storage\blob\baseblobservice.py”,第 600 行,在 create_container self._perform_request(request)
_perform_request raise ex 中的文件“c:\users\rb287jd\appdata\local\programs\python\python36\lib\site-packages\azure\storage\storageclient.py”,第 280 行
_perform_request 中的文件“c:\users\rb287jd\appdata\local\programs\python\python36\lib\site-packages\azure\storage\storageclient.py”,第 252 行引发 AzureException(ex.args[0])
AzureException: HTTPSConnectionPool(host='account_name.blob.core.windows.net', port=443): 最大重试次数超出 url: /cn1?restype=container (由 ConnectTimeoutError(, 'Connection to account_name.blob.core. windows.net 超时。(连接超时=20)'))