Bindings in Azure Functions

Bindings provide a declarative way to connect your Azure Functions to other services without having to write complex integration code. They define how your function is triggered and how it interacts with data.

What are Bindings?

Bindings in Azure Functions can be categorized into two main types:

Key Concepts

Common Binding Types

Input Bindings

Output Bindings

Example: Azure Blob Storage Input and Output Binding (function.json)

This example shows a function that reads an image from Blob Storage, processes it (conceptually), and writes a new image back.

{
  "scriptFile": "index.js",
  "bindings": [
    {
      "name": "myBlob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "samples-workitems/{name}.png",
      "connection": "AzureWebJobsStorage"
    },
    {
      "name": "inputImage",
      "type": "blob",
      "direction": "in",
      "path": "samples-workitems/{name}.png",
      "connection": "AzureWebJobsStorage"
    },
    {
      "name": "outputImage",
      "type": "blob",
      "direction": "out",
      "path": "samples-output/{name}-processed.png",
      "connection": "AzureWebJobsStorage"
    }
  ]
}

In this configuration:

  • myBlob is the trigger that starts the function when a new PNG file arrives in the samples-workitems container.
  • inputImage is an input binding that makes the content of the trigger blob available to the function.
  • outputImage is an output binding that allows the function to write data to a blob in the samples-output container.