Binding to a container or a list of blobs. #webjobs rocks

So I just learned today, that they (our friends at Microsoft), added support for binding to blob containers or a list of blobs, back in August of 2015. This WebJob thing is becoming more and more comfortable, which is extra nice, since most of the knowledge acquired - at least on a conceptual level - is transferrable to Microsoft's Serverless offering - it's Azure Functions. Speaking of which - check out the nice documentation over at https://docs.microsoft.com/en-us/azure/azure-functions/. What I did, was to download a PDF and then read the docs in peace on my iPad as I commute back and forth to the office.

Aaaaanyway... Binding. Check this out:

        public static async Task Handler(
            [QueueTrigger("input-queue")] Input input,
            [Blob("stuff/{BlobFolderNameAsDefinedInInput}")] IEnumerable< CloudBlockBlob> inputBlobs)
        {
           ... sweet, sweet code ...
        }

The two bindings above make the WebJobs runtime poll the input-queue queue for messages, deserialize their JSON message payload into the Input POCO and then create an enumerable collection of all of the blobs in my stuff blob container that starts with whatever was in the BlobFolderNameAsDefinedInInput property in the queue message. See the commit summary below:


If you, like me, missed this neat feature - you're welcome! :-)

Comments

Popular posts from this blog

Auto Mapper and Record Types - will they blend?

Unit testing your Azure functions - part 2: Queues and Blobs

Testing WCF services with user credentials and binary endpoints