Use the Azure portal to create a Service Bus topic and subscriptions to the topic
In this quickstart, you use the Azure portal to create a Service Bus topic and then create subscriptions to that topic.
What are Service Bus topics and subscriptions?
Service Bus topics and subscriptions support a publish/subscribe messaging communication model. When using topics and subscriptions, components of a distributed application do not communicate directly with each other; instead they exchange messages via a topic, which acts as an intermediary.
In contrast with Service Bus queues, in which each message is processed by a single consumer, topics and subscriptions provide a one-to-many form of communication, using a publish/subscribe pattern. It is possible to register multiple subscriptions to a topic. When a message is sent to a topic, it is then made available to each subscription to handle/process independently. A subscription to a topic resembles a virtual queue that receives copies of the messages that were sent to the topic. You can optionally register filter rules for a topic on a per-subscription basis, which allows you to filter or restrict which messages to a topic are received by which topic subscriptions.
Service Bus topics and subscriptions enable you to scale to process a large number of messages across a large number of users and applications.
Create a namespace in the Azure portal
To begin using Service Bus messaging entities in Azure, you must first create a namespace with a name that is unique across Azure. A namespace provides a scoping container for addressing Service Bus resources within your application.
To create a namespace:
Sign in to the Azure portal
In the left navigation pane of the portal, select + Create a resource, select Integration, and then select Service Bus.
In the Basics tag of the Create namespace page, follow these steps:
For Subscription, choose an Azure subscription in which to create the namespace.
For Resource group, choose an existing resource group in which the namespace will live, or create a new one.
Enter a name for the namespace. The system immediately checks to see if the name is available. For a list of rules for naming namespaces, see Create Namespace REST API.
For Location, choose the region in which your namespace should be hosted.1.
For Pricing tier, select the pricing tier (Basic, Standard, or Premium) for the namespace. If you want to use topics and subscriptions, choose either Standard or Premium. Topics/subscriptions are not supported in the Basic pricing tier. If you selected the Premium pricing tier, specify the number of messaging units. The premium tier provides resource isolation at the CPU and memory level so that each workload runs in isolation. This resource container is called a messaging unit. A premium namespace has at least one messaging unit. You can select 1, 2, or 4 messaging units for each Service Bus Premium namespace. For more information, see Service Bus Premium Messaging.
Select Review + create. The system now creates your namespace and enables it. You might have to wait several minutes as the system provisions resources for your account.
On the Review + create page, review settings, and select Create.
Select Go to resource on the deployment page.
You see the home page for your service bus namespace.
Get the connection string
Creating a new namespace automatically generates an initial Shared Access Signature (SAS) rule with an associated pair of primary and secondary keys that each grant full control over all aspects of the namespace. See Service Bus authentication and authorization for information about how to create rules with more constrained rights for regular senders and receivers. To copy the primary and secondary keys for your namespace, follow these steps:
Click All resources, then click the newly created namespace name.
In the namespace window, click Shared access policies.
In the Shared access policies screen, click RootManageSharedAccessKey.
In the Policy: RootManageSharedAccessKey window, click the copy button next to Primary Connection String, to copy the connection string to your clipboard for later use. Paste this value into Notepad or some other temporary location.
Repeat the previous step, copying and pasting the value of Primary key to a temporary location for later use.
Create a topic using the Azure portal
On the Service Bus Namespace page, select Topics on the left menu.
Select + Topic on the toolbar.
Enter a name for the topic. Leave the other options with their default values.
Create subscriptions to the topic
Select the topic that you created in the previous section.
On the Service Bus Topic page, select Subscriptions from the left menu, and then select + Subscription on the toolbar.
On the Create subscription page, follow these steps:
Enter S1 for name of the subscription.
Enter 3 for Max delivery count.
Then, select Create to create the subscription.
Repeat the previous step twice to create subscriptions named S2 and S3.
You can manage Service Bus resources with Service Bus Explorer. The Service Bus Explorer allows users to connect to a Service Bus namespace and administer messaging entities in an easy manner. The tool provides advanced features like import/export functionality or the ability to test topic, queues, subscriptions, relay services, notification hubs and events hubs.
In this article, you created a Service Bus namespace, a topic in the namespace, and three subscriptions to the topic. To learn how to publish messages to the topic and subscribe for messages from a subscription, see one of the following quickstarts in the Publish and subscribe for messages section.