Azure Functions Triggers and Bindings - Part 2 - Blob storage
This is part 2 of the Azure Functions Triggers and Bindings series where Triggers and Bindings are explored with C# examples. In this post, Azure Blob storage is explored with In-Process and Isolated Functions.
Triggers and Bindings
There are 3 use cases that we can take advantage of when dealing with Azure Blob storage on Azure Functions:
- Listen to blobs with
BlobTrigger, applied to both In-Process and Isolated models. - Read blobs from the storage with
BlobandBlobInput, an input binding applied to In-Process and Isolated models respectively. - Save blobs to the storage with
BlobandBlobOutput, an output binding applied to In-Process and Isolated models respectively.
Both triggers and bindings are explored below with In-Process and Isolated model examples.
They have similar implementations, except in Isolated mode, where bindings cannot handle Streams but only strings.
Triggers
A single trigger BlobTrigger is available in both implementations.
In-Process Triggers
The In-Process model leverages the NuGet package Microsoft.Azure.WebJobs.Extensions.Storage, version 5.0.1 (currently).
Trigger.cs
| |
Isolated Triggers
The Isolated model leverages the NuGet package Microsoft.Azure.Functions.Worker.Extensions.Storage, version 5.0.1 (currently).
Trigger.cs
| |
Testing Triggers
To validate the triggers, either start the In-process or Isolated model, then add a file to the blob container marketing by using Azure Storage Explorer.

- Create the blob container
marketing - Click to upload a file
- Select
Upload Files - Click to select a file
- Upload it
This should trigger the BlobTrigger function.
Bindings
There are 2 types of bindings, the Input used for reading blobs and the Output used for writing blobs.
In all examples below, there are different blob name patterns1 to make a trigger match.
Input In-Process Binding
Input.cs
| |
The implementation above gets triggered when a .txt file is uploaded to marketing-txt container, then with the Input binding it reads [Blob(“marketing-txt/{name}.txt”, FileAccess.Read)] the Stream just uploaded.
Input Isolated Binding
Input.cs
| |
The implementation above gets triggered when a .txt file is uploaded to marketing-txt container, then with the Input binding it reads [BlobInput(“marketing-txt/{name}.txt”, Connection = “AzureWebJobsStorage”)] the string just uploaded.
Output In-Process Binding
Output.cs
| |
The implementation above gets triggered when a .csv file is uploaded erroneously to marketing-txt container, then with the Output binding it writes [Blob(“marketing-csv/{name}.csv”, FileAccess.Write)] the Stream to another container marketing-csv, and within the implementation, the .csv file is deleted from marketing-txt.
Output Isolated Binding
Output.cs
| |
The implementation above gets triggered when a .csv file is uploaded erroneously to marketing-txt container, then with the Output binding it writes [BlobOutput(“marketing-csv/{name}.csv”, Connection = “AzureWebJobsStorage”)] the string to another container marketing-csv, and within the implementation, the .csv file is deleted from marketing-txt.
Testing Bindings
To validate the Input binding, create the container marketing-txt and then upload a .txt file to it. In this case, the function will print out the body of the .txt file uploaded.
Last, but not least, to validate the Output binding, create the container marketing-csv and then upload a .csv file to the marketing-txt container, as we are trying to check how the function is going to move files automatically.
The examples are available on PlayGoKids repository.
More posts will come to exemplify other Triggers and Bindings available in Azure Functions. Stay tuned.
References: blob name patterns ↩︎

Join the conversation! Share your thoughts and connect with other readers.