top of page

WELCOME TO CLOUD MATTER

Search
  • Writer's pictureRoman Guoussev-Donskoi

Patterns - Replicate API with Azure Service Bus Topics

Age-old scenario. Incoming API needs to be directed to several different end-points for processing.


For example this can come handy when re-writing old monolithic applications and transforming into new distributed solutions while still keeping old front API for backward compatibility with the existing clients.


Luckily (if asynchronous communication fits your use case) with Azure Service Bus topics this can be done in minutes. :)


Something like below:


If interested to try this scenario please see below.


Service Bus and Topic Setup

First create Azure Service Bus Namespace.


Now go to created Service Bus Namespace and create a topic


Then drill down into topic and create two subscribers



Create second subscriber the same as the first just name it trexsubscriber2.


Now topic should look like this.


Azure Functions

Lets create Azure functions now




Select Azure Service Bus Topic as Azure Function trigger


Install Service Bus Topic Extension

After Service Bus Topic extension is installed configure Azure Function Trigger by selecting "New" then selecting Service Bus Names space you previously created and setting the name of topic and the subscriber.




Function creation has been completed. You can review and update your configuration by clicking the angle in the right side as shown below.


Now create second function and bind it to the second topic you have created.

Both functions should look like below.



Testing

You can use Visual Studio to Submit messages to Topic.

Note: if you have corporate firewall you may have an issue at this step - there any many workarounds - for example deploy your code that submits messages into topic into Azure (e.g. you can use Azure Bots for this - just for fun).


But simplest method is probably below

https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dotnet-how-to-use-topics-subscriptions


Now you can see that each submitted message is processed by both Azure functions.

Go to "Monitor" tab for each function. (Note: it takes some time for monitoring messaged to appear)


Subscriber 1 Function:


Subscriber 2 Function:


You are done!


Next steps

If you want to add more complex processing into those Azure function just create a function project in Visual Studio and deploy into created functions.





34 views0 comments

Recent Posts

See All

Query SQL using OpenAI and Langchain

LLMs (such as OpenAI) are good for reasoning but they lack capability interface with outside world. This is where Langchain agents step in: agents provide LLMs with tools to perform actions (for examp

Home: Blog2

Subscribe

Home: GetSubscribers_Widget

CONTACT

Your details were sent successfully!

Computers
Home: Contact
bottom of page