- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个旧的 Azure 函数,它使用 BlockBlobService ->get_blob_to_bytes。如此处所述:https://github.com/uglide/azure-content/blob/master/articles/storage/storage-python-how-to-use-blob-storage.md#download-blobs
我相信我需要将 BlockBlobService 更新为 BlobServiceClient。但我在 BlobServiceClient 中找不到 get_blob_to_bytes?
Exception: AttributeError: 'BlobServiceClient' object has no attribute 'get_blob_to_bytes'
如何使用 BlobServiceClient 将 blob 转换为字节?
我得到了
Name: azure-storage-blob
Version: 12.16.0
但是没有 BlobClient.get_blob_to_bytes...或者至少当我尝试它时没有?
Edit3:为了进一步增加困惑,我正在使用队列中的消息。实例化 BlobClient 时需要 account_url、container_name 和 blob_name。如果您有 container 那就没问题了,但我有一个 queue .
有人吗?
最佳答案
But there is no BlobClient.get_blob_to_bytes.... Or atleast not when i try it??
是的,就像您提到的,BlobClient
中没有 get_blob_to_bytes()
。但是,您可以使用 download_blob().readall()
获得所需的结果。
from azure.storage.blob import BlobClient
connection_string="<CONNECTION_STRING>"
client = BlobClient.from_connection_string(connection_string,'container','abc.txt')
blob_bytes = client.download_blob().readall()
print(blob_bytes)
结果:
<小时/>
Edit3: To further add confusion, i 'm consuming messages from a Queue. And when instantiating a BlobClient is expects account_url, container_name and blob_name. Thats all well if you have a container, but i have a queue.
但是,由于您的要求是从队列中获取字节,请使用QueueClient
。您可以尝试以下方法来实现您的要求。
from azure.storage.queue import QueueClient
import base64
connection_string="<CONNECTION_STRING>"
queue = QueueClient.from_connection_string(conn_str=connection_string, queue_name='queue')
messages = queue.receive_messages()
for message in messages:
print(base64.b64decode(message.content).decode('utf-8').encode('utf-8'))
结果:
关于python - 新 BlobServiceClient 中的旧 BlockBlobService.get_blob_to_bytes 被什么替代?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76014556/
我收到以下错误: from azure.storage.blob import BlockBlobService ImportError: cannot import name 'BlockBlobS
根据this手册我应该使用这段代码: from azure.storage.blob import ContentSettings block_blob_service.create_block_bl
我有一个旧的 Azure 函数,它使用 BlockBlobService ->get_blob_to_bytes。如此处所述:https://github.com/uglide/azure-conte
我对使用 microsoft azure 服务还很陌生,并尝试按照 https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quic
自过去几周以来,我能够通过 python 包访问 azure 存储并创建 blob 并将 csv 上传到容器中。今天,当我尝试将大量 csv 上传到 blob 时,出现错误。 显然,当我运行 from
delete_blob() 似乎只删除容器内的文件以及容器内的文件夹和子文件夹中的文件。但当我尝试从容器中删除文件夹时,我在 python 中看到以下错误。 Client-Request-ID=795
我有一个 python3.6 脚本,需要从 Azure 中的 blob 存储中获取内容,我想在 Ubuntu 16.04 docker 容器中运行该脚本。 问题 我正在使用 this dockerfi
我是一名优秀的程序员,十分优秀!