Azure Service Bus Trigger Conditional Output Binding

상준 이 251 Reputation points
2021-09-14T02:00:07.3+00:00

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://learn.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?

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
544 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,262 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,238 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,516 Reputation points Microsoft Employee
    2021-09-14T14:45:08.217+00:00

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

    0 comments No comments