Darshan R
Darshan R

Reputation: 125

Azure Blob Storage Listing Blobs

I need a functionality for listing blobs from azure such that if I specify date, the list should only contain blobs created after that date.

Currently I am using BlobDirectory.ListBlobs() function which returns all the blobs. It also has a overloaded function which takes BlobRequestOptions as parameter. I have tried setting the AccessCondition in the BlobRequestOptions to AccessCondition.IfModifiedSince(Date.UTC.Now) but somehow it gives me all the blobs stored in the container.

Any suggestion on what I can do differently to get particular subset of blobs

Upvotes: 2

Views: 4190

Answers (4)

Jason Short
Jason Short

Reputation: 5324

Another thing you can do is keep an Storage Table with a list of the files. Use that as an index to find those you care about by filtering on the table. I have done with some code, but I was also totally in control of what is being written to the storage account (only my app does). So it wasn't too bad to implement.

Upvotes: 0

chrisb
chrisb

Reputation: 987

This article shows getting blobs older than a certain date http://blogs.msdn.com/b/avkashchauhan/archive/2011/07/29/programatically-deleting-older-blobs-in-windows-azure-storage.aspx

Obviously very simple to do change it to get blobs newer than a certain date.

Upvotes: 2

Jim O'Neil
Jim O'Neil

Reputation: 23784

I wouldn't think AccessCondition would apply to a listing of blobs, just an individual blob itself (though the documentation isn't clear). A quick HTTP trace would confirm whether the associate HTTP header is sent for that call.

If indeed it does apply to the ListBlobs() call, the resource would be the blob container itself. Therefore, I'd expect it to return either all of the blobs or none of the blobs in the container, depending on whether the container itelf had been modified since the provided date.

Upvotes: 0

Tom
Tom

Reputation: 1611

You can do a client side filter to get the data you want. So pull down the blobs and then filter them in code (using Linq or whatever you like) before surfacing the results.

Upvotes: 0

Related Questions