Understand Azure Service Bus


Azure Service Bus is a fully managed multi-tenant cloud messaging service. It is an enterprise integration message broker. It is used to decouple the application and service from each other. It is a more reliable and secure platform for asynchronously transferring the data and state. The data transfer between application and service using a message that is in binary format may contain XML, JSON or plain text. The Azure Service Bus fully integrates with Azure Services, such as Event Grid, Logic Apps, Functions, Dynamics 365, and Stream Analytics.

It is scoping container for all the message components. It may contain multiple queues and topics (within a single namespace). It often serves as an application container.

A Queue is used to send and receive messages. It enables us to store these messages until the receiver is available to receive such messages and process them. It allows one-way communication. The messages are in FIFO order in the queue (FIFO first in, first out) and are timestamped based on their arrival. It delivers messages in pull mode, for example - based on the request. It is more useful in point-to-point communication.
Azure Service Bus

It is also used like Queue to send and receive a message. Topics are more useful in publish-subscribe scenarios. It may have multiple independent subscribers and topic subscribers can receive the copy of each message sent to the topic. The subscriptions are named entities that are durably created but they can be optionally auto delete or expire.
Azure Service Bus
The service bus has advanced features that help us to resolve many complex messaging problems. Following are some key features provided by Service Bus.
Message sessions

Service Bus uses sessions to guarantee FIFO (first in, first out); however, it does not support the session in the basic tier. The message session enables us to joint and order unbounded sequences of related messages.

It enables chain subscription or queue to another topic or queue within the same namespace. When it is enabled, the service bus automatically removes the messages that are placed in the first queue or subscription and put them in the second queue or topic.

Service bus supports DLQ (dead letter queue) to hold the messages which cannot be delivered to any receiver. We can also remove or inspect them from the DLQ.
Scheduled delivery

We can schedule the delivery of messages to a topic or queue
Message deferral

When a subscriber or queue receives the message to process them but due to some special circumstances in the application, they cannot process, the entity has the option to defer retrieval of the message to a later point. This message remains in the queue or subscription.

Client-side batching enables a queue or topic to delay sending a message for a certain period of time. If any additional message is sent by the client, it transmits the message in a single batch.


When two or more operations are there together into an execution scope, this is called transaction. It ensures that all operations in a group either succeed or fail jointly.
Filtering and actions

The subscriber can filter which message they want to receive from the topic. We can define named subscription rules to filter messages.
Auto-delete on idle

Service bus enables us to specify the idle time after that the queue is automatically get deleted. We can set a minimum duration of 5 minutes.
Duplicate detection

Duplication of the message is happening when an application fails due to some fatal error immediately after it sends a message and gets restarted, so application instance believes that a prior message is delivered and it resent the message to the client. The queue or topics can discard any duplicate copies.
Geo-disaster recovery

It enables data processing to continue from a different location when Azure regions experience downtime.

Service bus supports HTTP/REST and AMQP 1.0 protocols. It also supports the security protocols, such as Shared Access Signatures (SAS), Role Based Access Control (RBAC) and Managed identities for Azure resources.

Create a namespace in the Azure portal

To use Service Bus messaging entities in Azure, we must create a namespace. The name of the namespace is unique across Azure. It is a scoping container for all the message components.
To create a namespace, sign into Azure Portal and in the left navigation pane, select "Create a resource" link and then select "Integration", and then select "Service Bus".
Azure Service Bus
In the "Create namespace" window, we need to fill-up the following information.

Name of the namespace. It must unique and must follow rules for naming namespace

Pricing Tier
There are three options for pricing tier: Basic, Standard, and Premium. The topics and subscription are not available in the basic tier. If we want to use these functionalities, we must select either Standard or Premium.

Select an Azure subscription

Resource group
We can select an existing resource group or create a new one in which the namespace will live.

The region in which our namespace should be hosted.
Azure Service Bus
By clicking the "Create" button, the system creates a namespace and deploys it. When service bus namespace is deployed successfully, we get a notification on the toolbar.
Azure Service Bus
Once service bus namespace is deployed successfully, it is available under our resource page as well as the home page.
When we create a namespace, initial SAS (Shared Access Signature) gets generated automatically with a pair of primary and secondary keys that each grants full access control on the namespace in all aspects. We can access keys from "Shared access policies" screen (select "RootManageSharedAccessKey").
Azure Service Bus
The connection strings defined here, are used to communicate with any component (like a queue, topic, etc.) that is created under the namespace.


Azure Service Bus is a fully managed multi-tenant cloud messaging service. It is used to decouple application and service from each other. It is a more reliable and secure platform for asynchronously transferring the data and state. It is easily integrated with Azure Services, such as Logic Apps, function, Dynamics 365, event grid, etc.

Similar Articles