Repo containing an example Azure Functions project that implements different types of input and output Bindings.
Here are some blog posts giving more context and explaining the examples a bit more:
- Using Triggers & Bindings in Azure Functions V2
- Dynamic output bindings in Azure Functions
- Azure Functions: Binding to a property
- Using (Table Storage) Bindings in Azure Functions
There are a few examples:
This example shows you how to copy the triggering Blob into another container by coding it out completely. The steps implemented:
- Connect to a Storage Account
- Create a BlobClient
- Get a reference to a container (and create it if it doesn't exist)
- Get a reference to a blob
- Upload the file
This example shows you the power of an output binding: only one line of code to copy the blob!
In this Function, we add a message to a queue for each word in the triggering Blob. The only line of code we
need for that is calling the Add()
method on the ICollector<T>
.
Dynamic output binding by using the Binder
class.
The HttpTrigger isn't bound to a generic HttpRequest
, but is TYPED to a RequestModel
. The platform takes care of the deserialization of the message body for you.
The return binding above the Function does a couple of things for you:
- It creates a Blob in the 'copied' container with a random GUID as the filename
- It automatically writes the output of the Function call into that Blob
The HttpTrigger isn't bound to a generic HttpRequest
, but is TYPED to a RequestModel
. The platform takes care of the deserialization of the message body for you.
The blob binding above the Function does a couple of things for you:
- It creates a Blob in the 'properties' container with the value of the
Identifier
property as the filename - It writes the message of the posted model into that Blob
In this Function example the Table Storage binding takes care of connecting to Table Storage.
We’re automatically getting an instance of a CloudTable
pointing to the right (partition of a) table, or even an instance of a typed entity, in the right storage account, all by simply specifying the binding the right way.