Azure Functions triggers and bindings concepts

In this article you learn the high-level concepts surrounding functions triggers and bindings.

Triggers are what cause a function to run. A trigger defines how a function is invoked and a function must have exactly one trigger. Triggers have associated data, which is often provided as the payload of the function.

Binding to a function is a way of declaratively connecting another resource to the function; bindings may be connected as input bindings, output bindings, or both. Data from bindings is provided to the function as parameters.

You can mix and match different bindings to suit your needs. Bindings are optional and a function might have one or multiple input and/or output bindings.

Triggers and bindings let you avoid hardcoding access to other services. Your function receives data (for example, the content of a queue message) in function parameters. You send data (for example, to create a queue message) by using the return value of the function.

Consider the following examples of how you could implement different functions.

Example scenario Trigger Input binding Output binding
A new queue message arrives which runs a function to write to another queue. Queue* None Queue*
A scheduled job reads Blob Storage contents and creates a new Cosmos DB document. Timer Blob Storage Cosmos DB
The Event Grid is used to read an image from Blob Storage and a document from Cosmos DB to send an email. Event Grid Blob Storage and Cosmos DB SendGrid
A webhook that uses Microsoft Graph to update an Excel sheet. HTTP None Microsoft Graph

* Represents different queues

These examples are not meant to be exhaustive, but are provided to illustrate how you can use triggers and bindings together.

Trigger and binding definitions

Triggers and bindings are defined differently depending on the development approach.

Platform Triggers and bindings are configured by...
C# class library      decorating methods and parameters with C# attributes
All others (including Azure portal)      updating function.json (schema)

The portal provides a UI for this configuration, but you can edit the file directly by opening the Advanced editor available via the Integrate tab of your function.

In .NET, the parameter type defines the data type for input data. For instance, use string to bind to the text of a queue trigger, a byte array to read as binary and a custom type to de-serialize to an object.

For languages that are dynamically typed such as JavaScript, use the dataType property in the function.json file. For example, to read the content of an HTTP request in binary format, set dataType to binary:

    "dataType": "binary",
    "type": "httpTrigger",
    "name": "req",
    "direction": "in"

Other options for dataType are stream and string.

Binding direction

All triggers and bindings have a direction property in the function.json file:

  • For triggers, the direction is always in
  • Input and output bindings use in and out
  • Some bindings support a special direction inout. If you use inout, only the Advanced editor is available via the Integrate tab in the portal.

When you use attributes in a class library to configure triggers and bindings, the direction is provided in an attribute constructor or inferred from the parameter type.

Supported bindings

This table shows the bindings that are supported in the major versions of the Azure Functions runtime:

Type 1.x 2.x and higher1 Trigger Input Output
Blob storage
Cosmos DB
Event Grid
Event Hubs
HTTP & webhooks
IoT Hub
Microsoft Graph
Excel tables
Microsoft Graph
OneDrive files
Microsoft Graph
Outlook email
Microsoft Graph
Microsoft Graph
Auth tokens
Mobile Apps
Notification Hubs
Queue storage
Service Bus
Table storage

1 Starting with the version 2.x runtime, all bindings except HTTP and Timer must be registered. See Register binding extensions.

For information about which bindings are in preview or are approved for production use, see Supported languages.


Next steps