An Azure Function Trigger is a part of a function’s stack that tells Azure how the function is invoked. The most common function triggers are HTTP, Timer, and Blob:
There are other trigger types aside from HTTP, Timer, and Blob:
Type | Purpose |
---|---|
Timer | Execute a function at a set interval. |
HTTP | Execute a function when an HTTP request is received. |
Blob | Execute a function when a file is uploaded or updated in Azure Blob storage. |
Queue | Execute a function when a message is added to an Azure Storage queue. |
Azure Cosmos DB | Execute a function when a document changes in a collection. |
Event Hub | Execute a function when an event hub receives a new event. |
Timer Triggers are defined using CRON syntax. Time Triggers CRON syntax puts the seconds first, then the minutes, hours, days, months, and days of the week.
The widget below shows a serverless timer function that sets the color of a LIFX bulb based on the outside temperature. The function fires every five minutes as indicated in the cron definition in the function.json file:
HTTP triggers execute function logic when they receive a HTTP request. Examples of HTTP requests are:
Several HTTP verb handlers can be contained in a function. This means that an entire application can be composed of serverless functions.
A sample HTTP trigger function is given below. It is similar to the typical express routing handler function, however, the serverless function below uses an HTTP post request to submit a link to a given subreddit:
HTTP triggers can be used for building:
This trigger executes a function when a file is uploaded or updated in Azure Blob storage. This function type can be used to:
Several other trigger types exist as Azure has trigger types for most use cases. This versatility allows developers to create a wide variety of applications using Azure Functions.