liveBook · Manning

Azure Functions trigger

As explained in Microsoft Azure in Action

An Azure Blob Storage trigger is an Azure Functions event binding that invokes a function when a specified blob-storage event occurs.

A trigger is the entry point that tells an Azure Function when to run. Every function has exactly one. A Blob Storage trigger runs the function when it detects a new or updated blob in a container; an HTTP trigger runs it when its web endpoint is called. Trigger data can also be passed into the function, so it has something to work on. section 8.2.1 section 8.6

Suppose incoming emails contain images that need resizing. A Logic App can copy each attachment into Blob Storage. A Blob Storage trigger then starts the resizing function when the file arrives—no one needs to press a Run button. section 2.2.21

To set up that function in the Azure portal:

  • Create a function from the Azure Blob Storage Trigger template and select its storage-account connection. section 2.2.18
  • Set the path to imagecontainer/{name}. The path identifies the container to watch, while {name} supplies the detected file’s name. section 2.2.18
  • If the function produces a resized file, add a separate Blob Storage output binding, such as imageoutputcontainer/{rand-guid}. The trigger starts the work; the output binding gives the result a destination. section 2.2.19

Another entry point: HTTP

For a function called by a web request, the HTTP trigger template replaces the blob trigger. Its Run method receives an HttpRequest parameter containing request data. When creating this kind of function, choose an authentication level—anonymous, function, or admin—appropriate to who may call it. section 8.2 section 8.2.1

Do not confuse a Function trigger with a Logic App trigger. Both start work, but a Logic App trigger starts a workflow, while a Function trigger invokes one function. In the email example, the Logic App starts when mail arrives; the function starts later, when the attachment reaches Blob Storage. section 2.2.10 section 2.2.21

How Microsoft Azure in Action covers it

How deep it goes
Defines the one-trigger rule, explains trigger data, and walks through portal configuration of a Blob Storage trigger; does not detail other trigger types.
Examples
Uses an email-attachment image resizer, a blob path containing {name}, and an HTTP-triggered Run method receiving HttpRequest.
What it assumes
Assumes a storage account and blob container are available for the image workflow, while defining what triggers do from the start.
What you can do after
Operate/configure it in the Azure portal to start image processing when a blob arrives, then test the flow by emailing an image.
How it connects
Connects Azure Functions to Blob Storage, HTTP requests, output bindings, and Logic Apps in an automated processing flow.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microsoft Azure in Action. The section links point to the parts of the book it draws on.