Adventures with Azure Functions: Blob Storage Triggers and Bindings

Azure Functions

The docs are a little lite on examples of Azure Functions using Azure Storage Blobs, so I took a couple of hours and created a few more examples that I will share in this article.

The code can be found at https://github.com/mattruma/MJR061.

You will first want to create the resources in Azure, follow the instructions at https://github.com/mattruma/MJR061#environment.

Triggers

The Blob storage trigger starts a function when a new or updated blob is detected.

I created trigger examples for the following:

Note: I was not able to get the POCO serializable as JSON to work, nor the CloudPageBlob and CloudAppendBlob, the latter two I suspect because of the way I was testing, I was just uploading a file using Storage Explorer and my thought is that it was expecting something different.

Input

The input binding allows you to read blob storage data as input to an Azure Function.

I created input binding examples for the following:

Additional input binding examples can be created using a lot of the code found in the previous Triggers section.

I used Queue Triggers to trigger the reading of the blob.

Output

The output binding allows you to modify and delete blob storage data in an Azure Function.

I created input binding examples for the following:

Additional output binding examples can be created using a lot of the code found in the previous Triggers section.

I used Http Triggers to trigger the writing of the blob.

I will probably add more as time goes on and will look at adding additional language support and other Azure Function Triggers and bindings.


Another interesting approach is to use Event Grid or Queue Triggers as a trigger for blobs.

One of the draw backs to the Blob Trigger is it could be upwards to 10 minutes before the Azure Functions responds to the new blob.

See The Important Differences Between Blob Triggers and Event Grid Triggers in Azure Functions for an excellent example on how to do this.

Leave a Reply

Your email address will not be published.