python - 属性错误: 'BlockBlobService' object has no attribute 'create_block_blob_from_path'

标签 python azure azure-sdk-python

根据this手册我应该使用这段代码:

from azure.storage.blob import ContentSettings
block_blob_service.create_block_blob_from_path(
    'mycontainer',
    'myblockblob',
    'sunset.png',
    content_settings=ContentSettings(content_type='image/png')
            )

但出现此错误:

AttributeError: 'BlockBlobService' object has no attribute 'create_block_blob_from_path'

git 以及 pip 尝试过

pip install azure-storage

最佳答案

与最新的 Python SDK 相比,我认为该教程已经过时了。我认为不再有 create_block_blob_from_path - 我查看了 sdk 代码( here )。 block blob 和页 blob 分别导入,方法为 create_blob_from_path

简单修正一下:

from azure.storage.blob import BlockBlobService
from azure.storage.file import ContentSettings
blob_service = BlockBlobService(account_name="<storagename>",account_key="<storagekey>")

content_settings = ContentSettings(content_type = "image/png")
blob_service.create_blob_from_path("mycontainer","myblockblob","sunset.png",content_settings)

关于python - 属性错误: 'BlockBlobService' object has no attribute 'create_block_blob_from_path' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35653457/

相关文章:

azure - 从缺少列 Power BI 的文件夹加载多个文件

azure - 应用程序洞察使用情况

azure - 使用 azure-sdk-for-python 将节点部署到 AKS 集群

Python 不替换 % 符号

python - with-block 中多个 __exit__ 调用的顺序是否总是确定的?

python - Azure 表存储 Python SDK,语法无效

azure - 证书错误 Azure 应用程序网关

python - pandas 数据框到字典列表

python - 是否可以从 Azure Python SDK 获取 ASC 位置?

Azure CLI 与 Python SDK