Closed fs-jaszczult closed 4 years ago
While I'm still not sure why the code in the OP doesn't work, I changed the function and now it works.
def delete_blobs(self, contains: str):
blobs = self.list_blobs(contains)
container_client = ContainerClient.from_connection_string(self.connect_str, self.container_name)
for blob_name in blobs:
# Verify blob file exists
if self.blob_file_exists(blob_name):
container_client.delete_blob(blob=blob_name)
You used delete_blobs in your first example Then you changed to using delete_blob with a for loop.
The batch operation delete_blobs seems to be bugged for me as well.
If your 'self.blob_file_exists()' function is creating another BlobServiceClient instance, it might be linked to that. I'm facing the same issue at the moment. Would be good to see the code for 'blob_file_exists()' if that's possible :)
Switching from BlobServiceClient to ContainerClient as demonstrated by OP, fixed my issue as well. But that maybe more to do with the how we instantiate and reuse ContainerClients as opposed to BlobServiceClients.
Which service(blob, file, queue) does this issue concern?
azure-storage-blob
Which version of the SDK was used? Please provide the output of
pip freeze
.azure-common==1.1.24 azure-core==1.1.1 azure-storage-blob==12.1.0 azure-storage-common==2.1.0
What problem was encountered?
I'm working on an azure blob wrapper class for my team members to use and can't get the ContainerClient.delete_blobs() function to work in my delete function. Here's the code throwing the error:
When attempting to delete a blob using the steps provided here, I get the following error message:
Have you found a mitigation/solution?
No, I have not.