Rediģēt

Kopīgot, izmantojot


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 you use topics and subscriptions, components of a distributed application don't communicate directly with each other; instead they exchange messages via a topic, which acts as an intermediary.

Image showing how topics and subscriptions work.

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's possible to register multiple subscriptions to a topic. When a message is sent to a topic, it's 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 subscriptions, 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 Service Bus resources (queues, topics, etc.) within your application.

To create a namespace:

  1. Sign in to the Azure portal.

  2. Navigate to the All services page.

  3. On the left navigation bar, select Integration from the list of categories, hover the mouse over Service Bus, and then select + button on the Service Bus tile.

    Image showing selection of Create a resource, Integration, and then Service Bus in the menu.

  4. In the Basics tag of the Create namespace page, follow these steps:

    1. For Subscription, choose an Azure subscription in which to create the namespace.

    2. For Resource group, choose an existing resource group in which the namespace will live, or create a new one.

    3. Enter a name for the namespace. The namespace name should adhere to the following naming conventions:

      • The name must be unique across Azure. The system immediately checks to see if the name is available.
      • The name length is at least 6 and at most 50 characters.
      • The name can contain only letters, numbers, hyphens “-“.
      • The name must start with a letter and end with a letter or number.
      • The name doesn't end with “-sb“ or “-mgmt“.
    4. For Location, choose the region in which your namespace should be hosted.

    5. For Pricing tier, select the pricing tier (Basic, Standard, or Premium) for the namespace. For this quickstart, select Standard.

      Important

      If you want to use topics and subscriptions, choose either Standard or Premium. Topics/subscriptions aren't 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, 4, 8 or 16 messaging units for each Service Bus Premium namespace. For more information, see Service Bus Premium Messaging.

    6. Select Review + create at the bottom of the page.

      Image showing the Create a namespace page

    7. On the Review + create page, review settings, and select Create.

  5. Once the deployment of the resource is successful, select Go to resource on the deployment page.

    Image showing the deployment succeeded page with the Go to resource link.

  6. You see the home page for your service bus namespace.

    Image showing the home page of the Service Bus namespace created.

Create a topic using the Azure portal

  1. On the Service Bus Namespace page, select Topics on the left menu.

  2. Select + Topic on the toolbar.

  3. Enter a name for the topic. Leave the other options with their default values.

  4. Select Create.

    Screenshot of the Create topic page.

Create subscriptions to the topic

  1. Select the topic that you created in the previous section.

    Screenshot of the Topics page with your topic selected.

  2. On the Service Bus Topic page, select Subscriptions from the left menu, and then select + Subscription on the toolbar.

    Screenshot of the Subscriptions page with the Add subscription button selected.

  3. On the Create subscription page, follow these steps:

    1. Enter S1 for name of the subscription.

    2. Then, select Create to create the subscription.

      Screenshot of the Create subscription page.

  4. Repeat the previous step twice to create subscriptions named S2 and S3.

Next steps

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.