Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
126 views
in Technique[技术] by (71.8m points)

c# - Single Azure function triggered by multiple buses

Is it possible to trigger the same azure function from multiple service bus triggers?

So the scenario I have is that I have two separate service buses that are for all intents and purposes sending the same message just from different sources. I want to know if it is possible to have a single azure function subcribe to both buses. Some akin to:

 public class TheFunction
    {
        public static async Task Run(
            [ServiceBusTrigger("%TopicNameA%", "%SubscriptionNameA%", Connection = "Default")]
            [ServiceBusTrigger("%TopicNameB%", "%SubscriptionNameB%", Connection = "Default")] SomeEventData event, ILogger log)
        {
            // do some shenanigans
        }
    }

Now I am aware that above isn't possible, but I hope it conveys the general idea of what I would like to achieve.

My fallback is just to have two separate but identical functions where each subscribes to one of the buses and just throws the event to some shared service that does the work.

NOTE: I am unable to send messages from different sources to the same bus. Not impossible, just not feasible to re-jig things within the given timeframe.

question from:https://stackoverflow.com/questions/65837519/single-azure-function-triggered-by-multiple-buses

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Is it possible to trigger the same azure function from multiple service bus triggers?

So the scenario I have is that I have two separate service buses that are for all intents and purposes sending the same message just from different sources. I want to know if it is possible to have a single azure function subcribe to both buses. Some akin to:

First of all, it is impossible to have multiple triggers in one function of azure function.

Just provide an idea, use the event grid based on the service bus to monitor the information inside the service bus.

Since the azure function can only use the trigger of the service bus but not the inputbinding of the service bus, you need to read the information in the function body.

View the documents below:

https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-to-event-grid-integration-concept#azure-portal-instructions


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...