Uploading Image to Azure from Raspi4 Python 3.8.0 - getting this error and haven't had any luck with the multitude of solutions I've tried. If anyone has solved this please advise!
Here's the result when I execute my code that calls on azure storage and tries to create a new blob for a picture to be uploaded to:
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>
Based on the error exception, it is due to Azure can't find the target container you specified in your code. If you have no container in your storage account, please follow this doc to create one.
As you have not shared your code, so just try the code below to upload a local image file:
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)
Result :
In my case, my container name is testc
.
Let me know if you have any more questions.