Azure Functions Bindings

Azure Functions Bindings

Bindings in Azure Functions are quite crucial. This Azure article will discuss different types of Bindings in Azure Functions.

Azure Functions Bindings

Azure Function bindings can be InPut or OutPut bindings. You can call the Bindings as the connection to the data within your Azure Function.

  • Input Bindings: When an Azure function receives the data, that is termed as Input Bindings.
  • Output Bindings: Output Bindings are precisely the opposite of the Input Bindings. This is the data that the Azure function sends.

Azure Function Multiple Output Bindings

Sometimes, you will have some scenarios where you must configure the Azure Function with multiple output bindings; if you consider a scenario where you will have to create an Azure Function that outputs the message to Azure Queue Storage, and the exact message you have to output in the Azure Table Storage as well.

You can able to achieve this using the Azure Function. We will see the steps to implement these scenarios using the Azure Portal.

Navigate to the Azure Function App you have created above, click on the Functions from the left navigation, and create an HTTP trigger function like the above.

Once your function is created, click on the Integration option from the left navigation on the Azure Function page.

Azure Function Multiple Output Bindings

Click on the + Add output under the Outputs Option as highlighted below

Azure Functions with Multiple Output Bindings

Choose the Binding type as Azure Queue storage on the Create Output window. Keep the other option as it is (Default values), and click on the OK button.

Multiple output in Azure Functions with C#

Again, click on the + Add output from the below window.

Multiple output in Azure Functions with C# Example

Again, On the Create Output window, choose the Binding type as Azure Table storage Keep the other option as it is (Default values) and click on the Ok button.

How to implement Azure Function Multiple Output Bindings

Now the Outputs section looks like below

How to implement Azure Function Multiple Output Bindings C#

Now, if you see your Function.json file, it looks like the below and contains the below code

{
  "bindings": [
    {
      "authLevel": "function",
      "name": "req",
      "type": "httpTrigger",
      "direction": "in",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "name": "$return",
      "type": "http",
      "direction": "out"
    },
    {
      "name": "outputQueueItem",
      "direction": "out",
      "type": "queue",
      "queueName": "outqueue",
      "connection": "AzureWebJobsStorage"
    },
    {
      "name": "outputTable",
      "direction": "out",
      "type": "table",
      "tableName": "outTable",
      "connection": "AzureWebJobsStorage"
    }
  ]
}

Now, as per the above code, function.json tells the Azure Function that you now have two output bindings. In this case, we want to output to a table named output table and a storage queue named out queue. 

Now, Finally, you need to modify the code of the run.csx file as per the business requirement and then click on the Test/Run button and then click on the Run button from the Input window.

You may also like following the articles below

Conclusion

In this article, we discussed different types of bindings in Azure Functions. Thanks for reading this article !!!