Azure Functions Bindings

Azure Functions Bindings

Bindings are quite important in the case of Azure Functions. In this Azure article, we will discuss different types of Bindings in Azure Functions.

Azure Functions Bindings

Azure Functions 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 exactly 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 will have to configure the Azure Function with multiple output bindings. If you will consider a scenario where you will have to create an Azure Function that outputs the message to Azure Queue Storage and the same 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, that you have created above and 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

On the Create Output window, choose the Binding type as Azure Queue storage 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 will 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 names 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 below articles

Conclusion

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