Skip to content

Trigger Binding Data

Mathew Charles edited this page Mar 24, 2017 · 4 revisions

The various trigger bindings make many useful metadata values available as part of the binding process. Since Azure Functions is built on the WebJobs SDK the same set of metadata properties made available by the SDK are available in functions. See the WebJobs SDK documentation here for the list of properties supported per binding.

For C# functions, the above linked documentation and examples are the same. However for other languages like Node.js, these values are made available to your function in different ways. For example, for Node.js functions, you can access these via context.bindingData. Here is an example EventHub function binding to multiple events and accessing the metadata arrays for each:

module.exports = function (context, events) {
    for (i = 0; i < events.length; i++)
    {
        // EventData properties can be accessed via binding data,
        // including custom properties, system properties, etc.
        var bindingData = context.bindingData,
            eventProperties = bindingData.propertiesArray[i],
            systemProperties = bindingData.systemPropertiesArray[i],
            id = input[i].value;

        context.log('EventId: %s, EnqueuedTime: %s, Sequence: %d, Index: %s',
            id,
            bindingData.enqueuedTimeUtcArray[i],
            bindingData.sequenceNumberArray[i],
            eventProperties.testIndex);
    }

    context.done();
}

Here's an example queue triggered function:

module.exports = function (context, message) {
    context.log('Node.js queue trigger function processed message', message);

    context.log('DequeueCount=%s', context.bindingData.dequeueCount);
    context.log('InsertionTime=%s', context.bindingData.insertionTime);

    context.done();
}

Learn

Azure Functions Basics

Advanced Concepts

Dotnet Functions

Java Functions

Node.js Functions

Python Functions

Host API's

Bindings

V2 Runtime

Contribute

Functions host

Language workers

Get Help

Other

Clone this wiki locally