Ojas Maru
Ojas Maru

Reputation: 459

Find a Blob in Azure Container

I have thousands & thousands of Blobs in a container, something like

Now my problem is that I want to find Blob having A001 in its name. I understand that ListBlobsWithPrefix looks for Blob starting with some text which is not the case for me. ListBlobs would bring all the blobs to my code and then I would have to search for the one. Is there any way where I can just get the blobs I am looking for.

Upvotes: 1

Views: 2111

Answers (3)

Antonello G. Bianchi
Antonello G. Bianchi

Reputation: 450

As of today there's a preview feature available in few regions to allow for Blob Storage indexing:

https://learn.microsoft.com/en-us/azure/storage/blobs/storage-manage-find-blobs?tabs=azure-portal

Hope they make it available soonn,

regards

Upvotes: 0

NavaRajan
NavaRajan

Reputation: 1860

Instead of searching, construct the blobname if its prefix is known and then try downloading the blob.If the blob doesnt found you will be getting 404 not found exception.

Upvotes: 0

David Makogon
David Makogon

Reputation: 71031

There's really no easy way to search a container for a specific blob (or set of blobs with a name pattern) aside from brute-force. And name prefixes, as you've guessed, won't help you either in this case.

What I typically advise folks to do is keep their searchable metadata somewhere else (maybe SQL DB, maybe MongoDB, doesn't really matter as long as it provides the search capability they need), with that data store containing a reference link to the exact blob. The blob name itself can also be stored in the metadata as one of the searchable properties.

Also: Once you get into the "thousands & thousands of blobs in a container," you'll find that pulling the blob names is going to take a while (which, again, I think you're seeing). Containers can certainly hold as many blobs as you want, but in that case, you really want to be accessing them directly, based on some other metadata, and not enumerating through the name list.

Upvotes: 2

Related Questions