2

I'm storing blobs in virtual folders, using the current date as folder name. I need the names of the blobs to be unique, but I also need to be able to search within the folders to pick certain files (e.g. filename startswith(id)).

Below is the code i'm using to store the blobs.

#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Blob;
public static async Task Run(string input, Binder binder, TraceWriter log)
{
   string path = 
   "container/{DateTime.UtcNow.ToString("yyyy/MM/dd/HH")}/{someid}-
   {someguid}.json";
   var attributes = new Attribute[]
   {    
     new BlobAttribute(path),
     new StorageAccountAttribute("<storage connection>")
    };    

    using (var writer = await binder.BindAsync<TextWriter>(attributes))
    {
      writer.Write(input);
    }
}

I know it is possible to search the folders using the SDK, but I really want to be able to do searches on virtual folders in a blob storage, using an imperative binding. E.g. i want to fetch all blobs stored the last 5 days.

Any ideas?

2 Answers 2

0

As far as I know, currently azure storage listblob method doesn't support search by time.

Firstly, the azure SDK also used the azure storage rest api listblob method. It only support prefix as the filter.

So I suggest you could try to set the file with the date as the prefix.

e.g 2017-2-15-xxxxx.txt

Then you could use "2017-2" as the prefix to list all the blob start with "2017-2".

More details about how to use it by using azure storage SDK, you could refer to this code sample.

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

Comments

0
  1. If you want to use blob trigger to process new blobs you can use "Name patterns", something like "path": "input/original-{name}". More details: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob

  2. You can store created time and blob path in azure storage table. So on step 1 you get all blob paths in time range and in step 2 you get all blobs. This approach needs additional code.

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.