0
votes

when I trying to upload a new blob to the blob container, I get the "The specified blob does not exist" error. This is very weird. I just want to create a new blob, with a new unique blob name.

The code I used are like this: self.blob_service.create_blob_from_bytes(self.container, item['id'] + '.jpg', item['data'])

Azure-Storage/2.1.0-2.1.0 (Python CPython 3.6.9; Linux 5.4.0-1031-azure)

Error Messages:

2020-11-11 08:18:45 [azure.storage.common.storageclient] INFO: Client-Request-ID=XXXXXX-9436-0017fa0372fd Receiving Response: Server-Timestamp=Wed, 11 Nov 2020 08:18:44 GMT, Server-Request-ID=XXXXXX-1703-b8cd58000000, HTTP Status Code=404, Message=The specified blob does not exist., Headers={'transfer-encoding': 'chunked', 'server': 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0', 'x-ms-request-id': 'XXXXXX-b8cd58000000', 'x-ms-client-request-id': 'XXXXX-9436-0017fa0372fd', 'x-ms-version': '2019-02-02', 'x-ms-error-code': 'BlobNotFound', 'date': 'Wed, 11 Nov 2020 08:18:44 GMT'}. 2020-11-11 08:18:45 [azure.storage.common.storageclient] INFO: Client-Request-ID=XXXXXX6-0017fa0372fd Received expected http error: Server-Timestamp=Wed, 11 Nov 2020 08:18:44 GMT, Server-Request-ID=XXXXXX3-b8cd58000000, HTTP status code=404, Exception=The specified blob does not exist. ErrorCode: BlobNotFound. 2020-11-11 08:18:45 [azure.storage.common.storageclient] INFO: Client-Request-ID=XXXXXXX-9436-0017fa0372fd Outgoing request: Method=PUT, Path=/xxxxx-images-int/fd4e0a863575d6ebe26b14d0c655c4ba.jpg, Query={'timeout': None}, Headers={'x-ms-blob-type': 'BlockBlob', 'x-ms-lease-id': None, 'If-Modified-Since': None, 'If-Unmodified-Since': None, 'If-Match': None, 'If-None-Match': None, 'x-ms-access-tier': None, 'Content-Length': '101445', 'x-ms-version': '2019-02-02', 'User-Agent': 'Azure-Storage/2.1.0-2.1.0 (Python CPython 3.6.9; Linux 5.4.0-1031-azure)', 'x-ms-client-request-id': 'xxxxxxxxxxb-9436-0017fa0372fd', 'x-ms-date': 'Wed, 11 Nov 2020 08:18:45 GMT', 'Authorization': 'REDACTED'}.

1

1 Answers

0
votes

install:

pip install azure-storage-blob

import:

import os
from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient

code:

blob_service_client = BlobServiceClient.from_connection_string(connect_str)
container_name = "test"
container_client = blob_service_client.get_container_client(container_name)
blob_client = blob_service_client.get_blob_client(container_name, "MyFirstBlob.txt")
blob_client.upload_blob(somestream, blob_type="BlockBlob")

Above code works fine on my side, please have a try.