简体   繁体   中英

Azure Functions output binding

I'm new to Azure Functions and I couldn't find a good explanation about output bindings.

For example, if I want to upload a blob to Azure Storage when is recommended to use output binding and when to manually upload (which are advantages/disadvantages in each case)?

And which is the difference between output binding as a parameter in the Run function, and as an attribute ?

Parameter:

[FunctionName("MyFunction")]
public static void Run([ServiceBusTrigger("myqeue")] Message message,
                       [Blob("output-container/{name}", FileAccess.Write)] Stream stream)
{ }

Attribute:

[FunctionName("MyFunction")]
[return: Blob("output-container/{name}")]
public static string Run([ServiceBusTrigger("myqeue")] Message message, ILogger log)
{ }

when is recommended to use output binding and when to manually upload (which are advantages/disadvantages in each case)?

Here is the clear overview of when to use output bindings and for which service gives what features when using output bindings!

As we know, Bindings cannot co-exist without Azure Function triggers and 2 types of bindings available: Input and Output .

  • Output Binding : Data sent by your function is an example of an output binding.

Let's discuss the 2 ways of using output binding: 1) Stored Queue's data from the blob container acts as output binding Scenario :

In the Azure Functions EF Core Http Trigger Context, Queue will be utilized as an output binding to store the data to the local storage once the data has been saved to the database.

Second, when data is added to the Queue store, a new function will be formed. In this case, the data in the queue will be saved in the Blob container as an output binding, with the queue serving as the input binding. By including the Blob property for each queue trigger, the Blob container is used as output binding.

2) Service bus queue from Azure storage acting as output binding Scenario: Firstly, upon triggering of HTTP request, the HTTP request body will be sent as a request to Server Bus-Queue by using an output binding. Secondly, after the message is sent to the server bus queue, function will be triggered and the data will be logged in the application.

Here is the blog article provided the use cases and features of each service in detailed format, thanks to Ashish Patel.

A storage queue can be the ideal choice if you want to create code as soon as possible or if you want to transmit each message to just one recipient/destination. Otherwise, Service Bus queues offer a lot more flexibility and possibilities.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM