找不到记录器 "azure.storage.common.storageclient" 的处理程序 - 尝试将图像从 raspi4 上传到 azure 存储

No handlers could be found for logger "azure.storage.common.storageclient" - Trying to upload image to azure storage from raspi4

从 Raspi4 Python 3.8.0 将图像上传到 Azure - 出现此错误并且我尝试过多种解决方案都没有成功。如果有人解决了请指教!

这是我执行调用 azure 存储的代码并尝试为要上传的图片创建新 blob 时的结果:

No handlers could be found for logger "azure.storage.common.storageclient"
Traceback (most recent call last):
  File "testazureblob.py", line 19, in <module>
    content_settings=ContentSettings(content_type='image/jpeg'))
  File "/usr/local/lib/python2.7/dist-packages/azure/storage/blob/blockblobservice.py", line 491, in create_blob_from_path
    standard_blob_tier=standard_blob_tier, cpk=cpk)
  File "/usr/local/lib/python2.7/dist-packages/azure/storage/blob/blockblobservice.py", line 633, in create_blob_from_stream
    timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/azure/storage/blob/blockblobservice.py", line 1258, in _put_blob
    return self._perform_request(request, _parse_base_properties)
  File "/usr/local/lib/python2.7/dist-packages/azure/storage/common/storageclient.py", line 446, in _perform_request
    raise ex
azure.common.AzureMissingResourceHttpError: The specified container does not exist. ErrorCode: ContainerNotFound
<?xml version="1.0" encoding="utf-8"?><Error><Code>ContainerNotFound</Code><Message>The specified container does not exist.
RequestId:79ef792a-901e-003e-2a00-030019000000
Time:2021-02-14T18:40:46.3224574Z</Message></Error>

根据错误异常,是由于Azure找不到您在代码中指定的目标容器。如果您的存储帐户中没有容器,请按照此文档创建一个。

由于您尚未分享您的代码,所以请尝试使用以下代码上传本地图片文件:

from azure.storage.blob import BlobClient

storage_connection_string='<storage account connection string >'
#specify your container name here
container_name = '<target container name>'
dest_image_name = 'testImage.jpg'

local_image_path = '<path of local image>'


blob_client = BlobClient.from_connection_string(storage_connection_string,container_name,dest_image_name)
with open(local_image_path, "rb") as stream:
    blob_client.upload_blob(stream, overwrite=True)

结果:

在我的例子中,我的容器名称是 testc。 如果您还有其他问题,请告诉我。