Skip to content

Chain Azure Functions together using input and output bindings

Steve Pettifer edited this page May 28, 2021 · 3 revisions

Input and Output Bindings

  • Bindings are a declarative way to connect to data from within code
  • Functions may have multiple bindings for different data elements
  • Note that triggers are a special case of input binding: as mentioned before, you must have exactly one trigger per function, but none or more other input and output bindings
  • Some common types:
    • Blob storage
    • Service bus queues
    • Cosmos DB
    • Event Hubs
    • Http endpoints
    • External files
    • External tables
  • Some binding types are extensible and you can write your own
  • Three props are mandatory for all bindings with one further prop mandatory on many. Individual bindings may have more properties
    • Name - defines func parm that youa cces data through
    • Type - type of the binding
    • Direction - data flow direction (i.e. input or output)
    • Connection - frequently required. Name of an app settings with the connection string
  • Bindings are defined in JSON and are contained in the function.json file
  • Binding expressions: Specialised text in function.json, function parms or code that is evaluated to yield a value on function invocation
  • Binding expression types:
    • App settings
    • Trigger filename
    • Trigger metadata
    • JSON payloads
    • New GUID
    • Current date and time
  • Most identified by being wrapped in percent signs

Input Bindings

  • Common types:
    • Azure Blob Storage
    • Azure Cosmos DB
    • Mobile Apps
      • Loads a record from a mobile table endpoint and passes it to function
    • Azure table storage

Output Bindings

  • Many types
  • Some can be both input and output bindings, but not all
  • Use them to send or store data
  • Common types:
    • Blob storage
    • Cosmos DB
    • Event hubs
    • Http
    • MS Graph
      • Write files to OneDrive, send email via Outlook, modify Excel data
    • Mobile apps
    • Notification hubs
    • Queue storage
    • Send grid
    • Service bus
    • Table storage
    • Twilio
  • Define the binding direction as out
  • Can apply both input and output bindings to a single function and they may be of the same type

Notes on the 'Read data with input bindings exercise'

As at May 2021 this exercise does not work if you follow it as described. Once you set up the input binding as the exercise directs you and you then test the function by submitting a valid id, you will get a 404. This seems to be because either the UI doesn't set up the binding correctly or the instructions are wrong, hard to say which. This has been a problem for some time as evidenced by this SO post, which also supplied the solution.

In the Document ID and Partition Key fields of the binding setup pane, enter {id} instead of just id. The call to the function with a valid id will now work as expected.