question

18253371 avatar image
0 Votes"
18253371 asked PramodValavala-MSFT answered

Azure Service Bus Trigger Conditional Output Binding

Azure Function provides triggers for Messaging resources such as Queue, Event Hub, and Service Bus in Azure. I am currently using Service Bus Trigger in Isolate process form in C# in .NET 5.

Let me explain the scenario I'm curious about.

A Service Bus Trigger -> B Service Bus Queue -> C Service Bus Trigger -> D Service Bus Queue -> E Service Bus Trigger -> F Service Bus Queue ... (Repeat)

In the case of the above structure, the Return String of the Service Bus is passed to the next Service Bus by specifying the output binding using the ServiceBusOutputAttribute, an attribute of the Isolate Process.

However, if an unwanted action that I can detect occurs during processing in A Service Bus Trigger, I want to send a message to D Service Bus Queue, not B Service Bus Queue, so that intermediate steps are skipped and processed. I've searched MSDN to get this behavior, but I can't find the answer I'm looking for, only similar answers.

https://docs.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide#bindings

If you look at the link above, you can see how to send messages to multiple Service Buses inside by defining a class with a section called 'Multiple output bindings'. However, this will bind B and D to the Service Bus Queue, so if I only need to input data to D, then B will contain null or string.Empty. Then, Service Bus detects string.Empty as input and handles string.Empty in Trigger connected to B.

Of course, you do not have to process string.Empty at the top of the trigger, but string.Empty is continuously passed to the output-bound service bus, and unwanted triggers are generated in a chain. Azure Function is a structure that is charged as much as the operating time, so if processing string.Empty, it will not be expensive, but I do not want to waste useless resources.

Is it possible to do what I want?

dotnet-csharpazure-functionsazure-service-bus
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

PramodValavala-MSFT avatar image
0 Votes"
PramodValavala-MSFT answered

@18253371 Haven't given this a shot yet but looking at the runtime code, explicitly setting the value to null should do the trick.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.