Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a reference of Azure blob by the full Uri not the blob name?

I 'm saving the uri of the file in the database in this form:

https://app.blob.core.windows.net/container/Accounts/Images/acc.jpg

But to delete it I need to pass only the blob name, when I try this

CloudBlockBlob blockBlob = Container.GetBlockBlobReference(uri);

The blob's full uri becomes:

https://app.blob.core.windows.net/container/https://app.blob.core.windows.net/container/Accounts/Images/acc.jpg

So I get 404 error (not found), I can do some trimming to the uri but that doesn't seem efficient. so is there a way to delete a blob/ get reference by its full URI?

like image 636
mshwf Avatar asked Feb 16 '17 14:02

mshwf


1 Answers

I did face similar issue , since i already had valid container reference this worked for me :

CloudBlockBlob blockblob = container.GetBlockBlobReference(new CloudBlockBlob(blobUri).Name);
like image 158
Amit Bhandari Avatar answered Oct 04 '22 09:10

Amit Bhandari