Azure Storage Blobs and Azure Function Triggers
In the previous story, I had a look at how to create a simple .NET Core client for an Azure Storage Queue and how to attach a trigger to it.
I will complete the application to store blobs.
What a blob storage is
When creating an Azure Functions App comes as a requirement creating also an Azure Storage Account:
In Consumption mode, it holds your files, using Azure Files. i.e. all you function files exist in there.
In addition, the script runtime (based on the WebJobs SDK) uses Blobs, Queues and Tables as part of its infrastructure. e.g. it uses that to synchronize the work between multiple instances. It also stores logging information there.
Here is an example of the storage account that I got when creating an Azure Function App
The code running in the client
When run the code will produce the following result:
Creating a function using a blob trigger
When creating a blob trigger from visual studio, you will be prompted for two parameters:
- Connection String, I will leave that empty and I will use the one already configured in “local.settings.json” pointing to the App Function Container and called “AzureWebJobsStorage”
- Path, it will contain the name of the container
After uploading a file:
Conclusions
Azure storage blobs are easy to use and to integrate and they are the cloud alternative to store files inside local folders on the server