Sending and Receiving Messages from Azure Service Bus Using Logic Apps - CloudFronts

Sending and Receiving Messages from Azure Service Bus Using Logic Apps

Azure Service Bus, paired with Logic Apps, offers a powerful combination for sending, receiving, and managing messages between different applications and services. In this blog, we’ll walk through the process of sending and receiving messages using Azure Service Bus and Logic Apps.

Steps to send and receive messages from service bus using logic app

Step 1: Create an Azure Service Bus Namespace

Navigate to the Azure Portal:

– Go to portal.azure.com and log in with your credentials.

Create a Service Bus Namespace:

– In the search bar at the top, type “Service Bus” and select Service Bus from the results.

– Click + Create to start the creation process.

– Fill in the required details:

  • Subscription: Select your Azure subscription.
  • Resource Group: Choose an existing resource group or create a new one.
  • Namespace Name: Enter a unique name for your Service Bus namespace
  • Region: Select a region that is close to your user base.
  • Pricing Tier: Choose the pricing tier that suits your needs (e.g., Basic, Standard).

Click Review + Create, and then Create to deploy the namespace.

Step 2: Create a Queue or Topic in the Service Bus Namespace

Access the Service Bus Namespace:

– After the namespace is deployed, navigate to it by clicking on the resource in the portal.

Create a Queue or Topic depending on your use case I am going to use:

– Creating a Queue:

  • In the left-hand menu, select Queues under Entities.
  • Click + Queue.
  • Provide a name for your queue (e.g., myQueue).
  • Adjust other settings like max size and message TTL if needed, then click Create.

Step 3: Create a Logic App to Send Messages to the Service Bus

Navigate to Logic Apps:

– In the Azure portal, use the search bar to find and select Logic Apps.

– Click + Create to start a new Logic App.

Configure Your Logic App:

– In the Basics tab, provide the following details:

  • Subscription: Select your subscription.
  • Resource Group: Choose your resource group.
  • Logic App Name: Enter a descriptive name for your Logic App (e.g., SendMessageApp).
  • Region: Choose the same region as your Service Bus.

– Click Review + Create, and then Create.

Design the Logic App:

– Once the Logic App is created, open the Logic Apps Designer and a trigger “When a HTTP request is received” along with POST request.

– Add a compose action and pass the input parameters.

– Go to Service bus –> Shared access policies –> Copy the Connection String Endpoint url

– Add action Service Send Message and paste the copied end point in Connection String.

– Pass the Output of compose in content.

– Add a response action and the logic app workflow.

– Now Copy the Url from trigger and paste it in postman hit the url.

– As soon as you hit the url you will get customer Id as response in postman body.

– Now Go to azure portal and check the run history I will see the Date and Status has been added for that particular customer id.

– Now, Let’s verify this particular message whether it has been sent at the logic level or not.

– Go to queue in my case Queue name Is “receivingqueue” –> Go to Service bus Explorer –> Click on Peek form Start.

– Now in order see the content/ Message select the sequence number

Step 4: Create a Logic App to Receive Messages from the Service Bus

– Create a New Logic App: Repeat the steps to create a new Logic App.

– Go to Logic app designer.

– Add the Trigger “When a message is received in a queue”.

– Add a compose action

– Add a Terminate action on Succeeded.

– Now to verify you check the run history of logic app you can we are getting the content in base64 Format

– You can decode it and check it’s the same data that we were sending.

Conclusion

We’ve successfully set up a messaging system with Logic Apps and Azure Service Bus by following these steps. This configuration makes it possible to automate workflows, integrate apps seamlessly, and create reliable cloud solutions. Whether you’re working with batch processing or real-time data, Azure’s tools give you the strength and flexibility you need to scale your business effectively.


Share Story :

SEARCH BLOGS :

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange