-
Notifications
You must be signed in to change notification settings - Fork 206
Binding Extensions
This page describes Non-Trigger Bindings and how to write them. To understand how the binding fits into the larger binding process, see The Binding Process.
A factory pattern is used to create bindings. An IBindingProvider is the factory and is used to create IBinding instances. Take a look at SampleAttributeBindingProvider as an example. It's TryCreateAsync method is called by the runtime for all job parameters, giving it a chance to return a binding. In general the implementation of TryCreateAsync will:
- inspect the ParameterInfo to see if it has the specific binding attribute applied to it (in this case SampleAttribute)
- determine whether the parameter Type is supported by the binding
- if so, the provider constructs and returns an IBinding for the parameter
An IBinding instance is what is used by the runtime bind process to do all the heavy lifting. It implements the following methods.
This method is responsible for binding to a parameter for a particular function invocation. There are two overloads that must be implemented. The first BindAsync(BindingContext context)
is the primary bind method. The context object includes route parameter binding data, etc. which may be needed by the binding if the binding supports route parameters. See FileBinding for an example of a binding that includes route parameters. The other bind method BindAsync(object value, ValueBindingContext context)
takes an input value. This overload in Dashboard invocation/replay scenarios, where the input value will be a string. The method must convert the value as necessary and bind to it. Generally, the first overload will call into the second after it produces a value.
This method is responsible for returning a ParameterDescriptor describing the parameter. Among other things, the ParameterDescriptor is the mechanism used to integrate with the WebJobs SDK Dashboard - it can return ParameterDisplayHints which dictate how the parameter is shown in the Dashboard.