1

I am trying to delete a blob from our Azure container. I am able to connect to it and list all the blobs following the code in this question: Upload and Delete Azure Storage Blob using azure-storage-blob or azure-storage


CONNECT_STR = "DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXXXXXXXXX;EndpointSuffix=core.windows.net"
CONTAINER_NAME = "containername/"
blob_name = "productionmap/oursoftware/intended_blob_to_use.csv"

container_client = ContainerClient.from_connection_string(conn_str=CONNECT_STR, container_name=CONTAINER_NAME)

# Delete blob
container_client.delete_blob(blob=blob_name)

I am able to list all the blobs. I have tried to use a for loop to loop through the blobs and getting the specific blob to delete:

for x in bloblist:
  if x.name == 'intended_blob_to_use.csv':
    print(x.name)
    container_client.delete_blob(blob=x)

Above code is able to get the specific blobs name through the print but cannot delete it. Therefore it shouldn't have to do with the name of my file. The error message I receive is:

Traceback (most recent call last):
  File "/tmp/interpreter-input-038d73c4-068f-421b-b349-2f61f486a36b.tmp", line 25, in <module>
    container_client.delete_blob(ourblobfile)
  File "/usr/share/tomcat8/.local/lib/python3.6/site-packages/azure/core/tracing/decorator.py", line 73, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/usr/share/tomcat8/.local/lib/python3.6/site-packages/azure/storage/blob/_container_client.py", line 1060, in delete_blob
    **kwargs)
  File "/usr/share/tomcat8/.local/lib/python3.6/site-packages/azure/core/tracing/decorator.py", line 73, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/usr/share/tomcat8/.local/lib/python3.6/site-packages/azure/storage/blob/_blob_client.py", line 1106, in delete_blob
    process_storage_error(error)
  File "/usr/share/tomcat8/.local/lib/python3.6/site-packages/azure/storage/blob/_shared/response_handlers.py", line 181, in process_storage_error
    exec("raise error from None")   # pylint: disable=exec-used # nosec
  File "<string>", line 1, in <module>
  File "/usr/share/tomcat8/.local/lib/python3.6/site-packages/azure/storage/blob/_blob_client.py", line 1104, in delete_blob
    self._client.blob.delete(**options)
  File "/usr/share/tomcat8/.local/lib/python3.6/site-packages/azure/storage/blob/_generated/operations/_blob_operations.py", line 589, in delete
    map_error(status_code=response.status_code, response=response, error_map=error_map)
  File "/usr/share/tomcat8/.local/lib/python3.6/site-packages/azure/core/exceptions.py", line 105, in map_error
    raise error
azure.core.exceptions.ResourceNotFoundError: The specified blob does not exist.
RequestId:ccd2f1dd-a01e-0078-4989-4d431e000000
Time:2022-04-11T09:49:05.7447809Z
ErrorCode:BlobNotFound
Content: <?xml version="1.0" encoding="utf-8"?><Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.
RequestId:ccd2f1dd-a01e-0078-4989-4d431e000000
Time:2022-04-11T09:49:05.7447809Z</Message></Error>`

How come I cannot delete it? I am passing a key through the connection string and that user has "Owner" set on the storage.

1
  • 2
    Please try by changing CONTAINER_NAME = "containername/" to CONTAINER_NAME = "containername" (essentially remove the trailing slash in the container name). Commented Apr 11, 2022 at 11:35

1 Answer 1

2

After reproducing from our end with the same code, we received the same error.

enter image description here

Like @Gaurav Mantri mentioned it is the extra trailing slash that caused the error which makes it point in a different path and causes BlobNotFound.

ErrorCode:BlobNotFound Content: BlobNotFoundThe specified blob does not exist. RequestId:c647b4cb-001e-002c-6ffa-4e4ea0000000 Time:2022-04-13T05:50:27.6230552Z

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.