How to create a topic with testdata in Azure ServiceBus

In this blogpost I will describe how to create a ServiceBus and a Topic in Microsoft Azure and how to push some sample data with the ServiceBus Explorer to it. In a following post I will describe how to work with ServiceBus filters.

Before you create the servicebus, you should download the servicebus explorer tool which you can find here: https://code.msdn.microsoft.com/windowsapps/Service-Bus-Explorer-f2abca5a

Create a ServiceBus Namespace

  1. Go to https://manage.windowsazure.com
  2. Navigate to ServiceBus
  3. Click on create and enter your data. If you want to use Topics, you need to create a Standard messaging tier:
    CreateSBNamespace
  4. Click on the check mark button at the bottom right side. Now you are ready to connect and push data to it

Connect to the ServiceBus

  1. Navigate to your service bus namespace and click on “Manage Connection Strings”:
    ManageSBConnectionString
  2. Copy the connection string under SAS with the name “RootManageSharedAccessKey”. It looks like Endpoint=sb://my-servicebus-name.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
  3. Start ServiceBus Explorer Tool
    1. Go to File – Connect
    2. Select “Enter connection string…” and paste the connection string.
    3. If you receive a proxy error – see Azure ServiceBus Explorer – Proxy Authentication Error

Create a Topic and Subscription in the ServiceBus

  1. Create a new Topic by right clicking “Topics” and “Create Topic”. (you can also do this in the Azure portal)
    1. Give it a relative URI like “messages” and click on “Create”:
      CreateTopicSBExplorer
  2. Create a new subscription under the newly created topic
    1. Give it name – e.g. “All” and set the Max Delivery Count to a useful number (1000)
      CreateSBSubscriptionSBExplorer
    2. If you want to test and debug your servicebus, then I also suggest you to create a subscription for debugging purposes. This subscription holds messages for 1 hour and then it deletes those messages. You can create such a subscription by giving it a name like “Debug” and set “Default Message Time To Live” to 1 hour.

Send testdata (messages) to your ServiceBus

  1. Right click on the topic and click “Send Messages”
    SendMessagesToSBwithSBExplorer
  2. Enter some data to the message text and to the message properties. In the “Sender” tab you can configure how much messages you want to send by clicking the “Start” button.
  3. Click “Start” to send messages to the servicebus.
  4. Close the window and refresh the subscription
    1. You should now see that the number right to the subscription changed.
    2. Get the messages by selecting the subscription, click on Messages and peek some of them:
      ReceiveMessageWithSBExplorer

Additional information

How to use Service Bus topics and subscriptions: https://azure.microsoft.com/en-us/documentation/articles/service-bus-dotnet-how-to-use-topics-subscriptions/

Categories:

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *

About
about armin

Armin Reiter
Blockchain/Web3, IT-Security & Azure
Vienna, Austria

Reiter ITS Logo

Cryptix Logo

Legal information