Triggers and bindings in Azure Functions (2024)

  • Article

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

Triggers cause a function to run. A trigger defines how a function is invoked and a function must have exactly one trigger. Triggers can also pass data into your function, as you would with method calls.

Binding to a function is a way of declaratively connecting your functions to other resources; bindings either pass data into your function (an input binding) or enable you to write data out from your function (an output binding) using binding parameters. Your function trigger is essentially a special type of input binding.

You can mix and match different bindings to suit your function's specific scenario. 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 scenarioTriggerInput bindingOutput binding
A new queue message arrives which runs a function to write to another queue.Queue*NoneQueue*
A scheduled job reads Blob Storage contents and creates a new Azure Cosmos DB document.TimerBlob StorageAzure Cosmos DB
The Event Grid is used to read an image from Blob Storage and a document from Azure Cosmos DB to send an email.Event GridBlob Storage and Azure Cosmos DBSendGrid

* Represents different queues

These examples aren't meant to be exhaustive, but are provided to illustrate how you can use triggers and bindings together. For a more comprehensive set of scenarios, see Azure Functions scenarios.

Tip

Functions doesn't require you to use input and output bindings to connect to Azure services. You can always create an Azure SDK client in your code and use it instead for your data transfers. For more information, see Connect to services.

Trigger and binding definitions

Triggers and bindings are defined differently depending on the development language. Make sure to select your language at the top of the article.

Bindings can be either input or output bindings. Not all services support both input and output bindings. See your specific binding extension for specific bindings code examples.

This example shows an HTTP triggered function with an output binding that writes a message to an Azure Storage queue.

For C# class library functions, triggers and bindings are configured by decorating methods and parameters with C# attributes, where the specific attribute applied might depend on the C# runtime model:

  • Isolated worker model
  • In-process model

The HTTP trigger (HttpTrigger) is defined on the Run method for a function named HttpExample that returns a MultiResponse object:

[Function("HttpExample")]public static MultiResponse Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req, FunctionContext executionContext){

This example shows the MultiResponse object definition which both returns an HttpResponse to the HTTP request and also writes a message to a storage queue using a QueueOutput binding:

public class MultiResponse{ [QueueOutput("outqueue",Connection = "AzureWebJobsStorage")] public string[] Messages { get; set; } public HttpResponseData HttpResponse { get; set; }}

For more information, see the C# isolated worker model guide.

Legacy C# Script functions use a function.json definition file. For more information, see the Azure Functions C# script (.csx) developer reference.

For Java functions, triggers and bindings are configured by annotating specific methods and parameters. This HTTP trigger (@HttpTrigger) is defined on the run method for a function named HttpTriggerQueueOutput, which writes to a storage queue defined by the @QueueOutput annotation on the message parameter:

@FunctionName("HttpExample")public HttpResponseMessage run( @HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request, @QueueOutput(name = "msg", queueName = "outqueue", connection = "AzureWebJobsStorage") OutputBinding<String> msg, final ExecutionContext context) { context.getLogger().info("Java HTTP trigger processed a request.");

For more information, see the Java developer guide.

The way that triggers and binding are defined for Node.js functions depends on the specific version of Node.js for Functions:

  • v4
  • v3

In Node.js for Functions version 4, you configure triggers and bindings using objects exported from the @azure/functions module. For more information, see the Node.js developer guide.

This example is an HTTP triggered function that creates a queue item for each HTTP request received.

  • v4
  • v3

The http method on the exported app object defines an HTTP trigger, and the storageQueue method on output defines an output binding on this trigger.

const { app, output } = require('@azure/functions');const queueOutput = output.storageQueue({ queueName: 'outqueue', connection: 'MyStorageConnectionAppSetting',});app.http('httpTrigger1', { methods: ['GET', 'POST'], authLevel: 'anonymous', extraOutputs: [queueOutput], handler: async (request, context) => { const body = await request.text(); context.extraOutputs.set(queueOutput, body); return { body: 'Created queue item.' }; },});
  • v4
  • v3

The http method on the exported app object defines an HTTP trigger, and the storageQueue method on output defines an output binding on this trigger.

import { app, HttpRequest, HttpResponseInit, InvocationContext, output } from '@azure/functions';const queueOutput = output.storageQueue({ queueName: 'outqueue', connection: 'MyStorageConnectionAppSetting',});export async function httpTrigger1(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> { const body = await request.text(); context.extraOutputs.set(queueOutput, body); return { body: 'Created queue item.' };}app.http('httpTrigger1', { methods: ['GET', 'POST'], authLevel: 'anonymous', extraOutputs: [queueOutput], handler: httpTrigger1,});

This example function.json file defines the function:

 { "authLevel": "function", "type": "httpTrigger", "direction": "in", "name": "Request", "methods": [ "get", "post" ] }, { "type": "http", "direction": "out", "name": "Response" }, { "type": "queue", "direction": "out", "name": "msg", "queueName": "outqueue", "connection": "AzureWebJobsStorage" } ]}

For more information, see the PowerShell developer guide.

The way that the function is defined depends on the version of Python for Functions:

  • v2
  • v1

In Python for Functions version 2, you define the function directly in code using decorators.

app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)@app.route(route="HttpExample")@app.queue_output(arg_name="msg", queue_name="outqueue", connection="AzureWebJobsStorage")def HttpExample(req: func.HttpRequest, msg: func.Out [func.QueueMessage]) -> func.HttpResponse: logging.info('Python HTTP trigger function processed a request.')

Add bindings to a function

You can connect your function to other services by using input or output bindings. Add a binding by adding its specific definitions to your function. To learn how, see Add bindings to an existing function in Azure Functions.

Supported bindings

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

Type1.x12.x and higher2TriggerInputOutput
Blob storage
Azure Cosmos DB
Azure Data Explorer
Azure SQL
Dapr4
Event Grid
Event Hubs
HTTP & webhooks
IoT Hub
Kafka3
Mobile Apps
Notification Hubs
Queue storage
Redis
RabbitMQ3
SendGrid
Service Bus
SignalR
Table storage
Timer
Twilio

Notes:

  1. Support will end for version 1.x of the Azure Functions runtime on September 14, 2026. We highly recommend that you migrate your apps to version 4.x for full support.
  2. Starting with the version 2.x runtime, all bindings except HTTP and Timer must be registered. See Register binding extensions.
  3. Triggers aren't supported in the Consumption plan. Requires runtime-driven triggers.
  4. Supported in Kubernetes, IoT Edge, and other self-hosted modes only.

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

Specific binding extension versions are only supported while the underlying service SDK is supported. Changes to support in the underlying service SDK version affect the support for the consuming extension.

Bindings code examples

Use the following table to find more examples of specific binding types that show you how to work with bindings in your functions. First, choose the language tab that corresponds to your project.

Binding code for C# depends on the specific process model.

  • Isolated process
  • In-process
ServiceExamplesSamples
Blob storageTrigger
Input
Output
Link
Azure Cosmos DBTrigger
Input
Output
Link
Azure Data ExplorerInput
Output
Link
Azure SQLTrigger
Input
Output
Link
Event GridTrigger
Output
Link
Event HubsTrigger
Output
IoT HubTrigger
Output
HTTPTriggerLink
Queue storageTrigger
Output
Link
RabbitMQTrigger
Output
SendGridOutput
Service BusTrigger
Output
Link
SignalRTrigger
Input
Output
Table storageInput
Output
TimerTriggerLink
TwilioOutputLink
ServiceExamplesSamples
Blob storageTrigger
Input
Output
Link
Azure Cosmos DBTrigger
Input
Output
Link
Azure Data ExplorerInput
Output
Link
Azure SQLTrigger
Input
Output
Event GridTrigger
Output
Link
Event HubsTrigger
Output
IoT HubTrigger
Output
HTTPTriggerLink
Queue storageTrigger
Output
Link
RabbitMQTrigger
Output
SendGridOutput
Service BusTrigger
Output
Link
SignalRTrigger
Input
Output
Table storageInput
Output
TimerTriggerLink
TwilioOutputLink
ServiceExamplesSamples
Blob storageTrigger
Input
Output
Link
Azure Cosmos DBTrigger
Input
Output
Link
Azure Data ExplorerInput
Output
Azure SQLTrigger
Input
Output
Link
Event GridTrigger
Output
Link
Event HubsTrigger
Output
IoT HubTrigger
Output
HTTPTriggerLink
Queue storageTrigger
Output
Link
RabbitMQTrigger
Output
SendGridOutput
Service BusTrigger
Output
Link
SignalRTrigger
Input
Output
Table storageInput
Output
TimerTriggerLink
TwilioOutputLink
ServiceExamplesSamples
Blob storageTrigger
Input
Output
Link
Azure Cosmos DBTrigger
Input
Output
Link
Azure SQLTrigger
Input
Output
Event GridTrigger
Output
Link
Event HubsTrigger
Output
IoT HubTrigger
Output
HTTPTriggerLink
Queue storageTrigger
Output
Link
RabbitMQTrigger
Output
SendGridOutput
Service BusTrigger
Output
Link
SignalRTrigger
Input
Output
Table storageInput
Output
TimerTriggerLink
TwilioOutputLink

Binding code for Python depends on the Python model version.

  • v2
  • v1
ServiceExamplesSamples
Blob storageTrigger
Input
Output
Link
Azure Cosmos DBTrigger
Input
Output
Link
Azure Data ExplorerInput
Output
Azure SQLTrigger
Input
Output
Link
Event GridTrigger
Output
Link
Event HubsTrigger
Output
IoT HubTrigger
Output
HTTPTriggerLink
Queue storageTrigger
Output
Link
RabbitMQTrigger
Output
SendGridOutput
Service BusTrigger
Output
Link
SignalRTrigger
Input
Output
Table storageInput
Output
TimerTriggerLink
TwilioOutputLink

Custom bindings

You can create custom input and output bindings. Bindings must be authored in .NET, but can be consumed from any supported language. For more information about creating custom bindings, see Creating custom input and output bindings.

Related content

Triggers and bindings in Azure Functions (2024)
Top Articles
Why day-of-the-week investing is a no-go strategy
Getting started with Stripe: create or connect an account : Stripe: Help & Support
Moon Stone Pokemon Heart Gold
Meer klaarheid bij toewijzing rechter
877-668-5260 | 18776685260 - Robocaller Warning!
Mikayla Campinos Videos: A Deep Dive Into The Rising Star
True Statement About A Crown Dependency Crossword
Bubbles Hair Salon Woodbridge Va
Transformers Movie Wiki
Craiglist Galveston
Craigslist Mpls Cars And Trucks
Becu Turbotax Discount Code
Eva Mastromatteo Erie Pa
Palm Coast Permits Online
Webcentral Cuny
Craigslist In Flagstaff
Video shows two planes collide while taxiing at airport | CNN
Violent Night Showtimes Near Amc Fashion Valley 18
1773X To
Welcome to GradeBook
Craigslist Appomattox Va
Azpeople View Paycheck/W2
The EyeDoctors Optometrists, 1835 NW Topeka Blvd, Topeka, KS 66608, US - MapQuest
The Eight of Cups Tarot Card Meaning - The Ultimate Guide
UCLA Study Abroad | International Education Office
Goodwill Of Central Iowa Outlet Des Moines Photos
Tim Steele Taylorsville Nc
Uncovering the Enigmatic Trish Stratus: From Net Worth to Personal Life
Japanese Emoticons Stars
Sony Wf-1000Xm4 Controls
Gridwords Factoring 1 Answers Pdf
Fridley Tsa Precheck
Xemu Vs Cxbx
Colorado Parks And Wildlife Reissue List
Ishow Speed Dick Leak
Boggle BrainBusters: Find 7 States | BOOMER Magazine
Pawn Shop Open Now
Craigslist Jobs Brownsville Tx
SF bay area cars & trucks "chevrolet 50" - craigslist
9 oplossingen voor het laptoptouchpad dat niet werkt in Windows - TWCB (NL)
062203010
Devon Lannigan Obituary
فیلم گارد ساحلی زیرنویس فارسی بدون سانسور تاینی موویز
Penny Paws San Antonio Photos
Lawrence E. Moon Funeral Home | Flint, Michigan
Latina Webcam Lesbian
2000 Fortnite Symbols
Autozone Battery Hold Down
O.c Craigslist
Unity Webgl Extreme Race
Latest Posts
Article information

Author: Tyson Zemlak

Last Updated:

Views: 6298

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Tyson Zemlak

Birthday: 1992-03-17

Address: Apt. 662 96191 Quigley Dam, Kubview, MA 42013

Phone: +441678032891

Job: Community-Services Orchestrator

Hobby: Coffee roasting, Calligraphy, Metalworking, Fashion, Vehicle restoration, Shopping, Photography

Introduction: My name is Tyson Zemlak, I am a excited, light, sparkling, super, open, fair, magnificent person who loves writing and wants to share my knowledge and understanding with you.