How to use Azure Service bus Queues

In this article, we will discuss What are Azure service bus queues and how to use Azure service bus queues in real-time. Along with that, we will discuss a few other topics, as mentioned below.

What are Azure Service bus Queues?

Queues are the main concepts of Azure Service Bus.

Azure Service bus Queues are part of the Azure messaging service, which supports queueing mechanisms. Messages are queued and then processed using the First-in-first-out mechanism.

azure service bus queue architecture

Note that Azure Service bus Queues are different than Azure Storage Queues. You can check out Azure Storage Queue vs Service Bus to know the key differences between both of them.

How to use Azure Service bus Queues

To use the Azure Service bus Queues we need to perform the below steps.

  1. Create Azure Service bus namespace
  2. Creating a Queue in the Service bus namespace
  3. Sending a message to the Queue
  4. Peeking a message from the Queue
  5. Receiving a message from the Queue

Now, to use the Azure Service bus Queues, the first thing we need to create the Azure Service bus namespace.

Related: Azure service bus pricing

How to create Azure Service bus namespace

Well, it is so simple to create an Azure Service bus namespace in Azure Portal using the below steps.

  1. Log in to the Azure Portal.
  2. Search for Service bus and click on the search result Service Bus under Services.
How to create Azure Service bus

3. Click on the + Create button on the Service Bus page or you can click on the Create service bus namespace button to create a service bus namespace.

how to use azure service bus
how to use service bus in Azure

4. On the Create namespace page, select the Basics tab and then provide the below details

  • Subscription: Select a valid Azure Subscription.
  • Resource Group: Click on the Create new link to create a new Resource Group or you can select an existing Resource Group.
  • Namespace name: Provide a unique name for your Service bus namespace.
  • Location: Choose the location or Region,
  • Pricing tier: Choose the Pricing tier based on your requirement, You can click on the “Browse the available plans and their features” link to check out all the pricing tiers and then choose the one that best suits your requirement.

Leave all the values in the other tabs as it is and then click on the Review + Create button.

How to create Azure Service bus namespace

5. Now, the system will validate all the details you entered. Once all the details are valid, it will show you Validation Succeeded, and the Create button will be enabled. Click on the Create button to create the Azure Service bus namespace.

create Azure Service bus namespace

6. Click on the Go to Resource button to navigate to the Azure Service bus namespace.

what is service bus in azure

A namespace contains the Queues, So let’s create a Queue in the namespace.

Creating a Queue in the Service bus namespace

To create the queue in the Service bus namespace, follow the below steps

7. On the Service Bus Namespace page, click on the + Queue button.

Creating a Queue in the Service bus namespace

8. On the Create queue window, provide the below details.

  • Name: Provide a unique name for the Queue.
  • Max queue Size: Specify a max queue size.
  • Max delivery count: Specify the maximum delivery count.
  • Enable the other features like “Enable duplicate detection”, “Enable auto-delete on idle queue”, etc based on your requirement.

Finally, click on the Create button to create the queue inside the Service bus namespace.

How to Create a Queue in the Service bus namespace

9. To find the Queue you have created at the last step, Click on the Queues link from the left navigation on the Service Bus Namespace page.

How to Create a Queue in Service bus namespace

Sending a message to the Queue

Now that our Queue is ready so as a next step, I will send a message to the Queue I have created.

10. Click