I'm working on microservices (using Azure Function Apps) that contain ServiceBusTrigger
-based Azure Functions that trigger when a message is inserted into a Service Bus Queue.
I'm trying to determine the best way of binding output values to multiple targets (e.g. CosmosDB and IoT Hub). Whether or not the method is marked as async will determine how I should approach this problem.
As far as I am aware, the way that you would typically handle output binding with an async function is by using the [return: ...]
annotation; however, in my use case, I need to return two different values to two separate targets (e.g. CosmosDb and IoT Hub). I don't think that this is something that I can achieve with return value binding or output variable binding, since you can't have an out
param with an async method and you can define multiple return values with the [return: ...]
approach.
It would seem that my only option (if I went the async route) would be to manually invoke SDK methods in the Azure Function to call the services independent of any output values. I'm trying to avoid doing that, seeing as output binding is the preferred approach.
An observation that I have made when creating a brand new ServiceBusTrigger
-based Azure Function is that the generated method signature is not marked as async
by default.
This is different than an HttpTrigger
, which is marked as async
out-of-box.
Can someone help me understand the reasoning for this? What are the scaling implications associated with one vs. the other?
I understand in a traditional sense why you typically mark an HttpTrigger
as async; however, I don't understand the reasoning as to why the ServiceBusTrigger
is not async
I need to understand this bit before I can move on with solidifying my approach to outputs.