4. Azure Service Bus

Set up and configure an Azure Service Bus instance that is used to transport new order events from commercetools to Marketplacer

Build Outcome

By the end of this section we will have:

  • Created an Azure Service Bus instance
  • Added a Topic to the service bus
  • Added a Subscription to the Topic
  • Create a Shared Access Policy


Create Azure Service Bus

Login to the Azure portal and:

1: Select Create a resource

Create Azure Resource

2: Search for “Azure Service Bus” and select Service Bus by Microsoft:

Azure Service Bus

3: Click Create and complete the fields in the Create namespace form, ensuring that you set your own suitable values for the following fields:

  • Resource Group
  • Namespace name
  • Location

Azure Service Bus Namespace

4: You can choose to move through the rest of the service bus namespace set up, or select Review + create as the default values will suffice for this tutorial:

Azure Service Bus Namespace

5: When you are happy with the configuration, click Create and Azure will start to provision the service.

Create service bus

6: When the deployment is complete, click Go to resource so that we can set up our Topic:

Go to resource

Create Topic

7: With the newly created service bus namespace selected, click on + Topic:

Create Topic

8: Complete the fields exactly as shown below, and then click Create:

Create Topic Form

Azure will provision the Topic on the service bus, and you should eventually see: Your topic was successfully completed message:

Create Topic Form

Create a Subscription

Having created a Topic on which commercetools can publish created order messages, we now need to create a Subscription on that Topic. This subscription is used by our 2nd Azure Function to receive message notifications on the service bus.

9: On the service bus namespace page in the Azure Portal, scroll down the page and select Topics:

Select Topic

10: Click on the orders topic that we created in the last section:

Orders Topic

11: On the orders topic page, select + Subscription:

Orders Topic

12: Complete the name as shown below and click Create when ready:

Create Subscription

When Azure has provisioned the Subscription, you should receive a Successfully created Service Bus subscription S1 message:

Subscription Created

13: You can further validate the status of the subscription by scrolling down the order topic page:

Active Subscription

Create a Shared Access Policy

Ultimately we want to allow commercetools to publish a message to our orders topic, so that we can achieve this we need to set a Shared Access Policy (SAS).

More information on this can be found in the commercetools documentation.

14: Back in the Azure Portal, ensure you are on the orders topic page, and select Shared access policies:

Create Shared Access Policy

15: Click + Add:

Add Shared Access Policy

16: Give your SAS a name, and ensure the Send permission is selected. When you’re happy, click Create:

Shared Access Policy

Azure will provision the SAS for you, and when completed you should receive the Successfully created SAS policy… message:

Shared Access Policy Created

17: Select the newly created SAS:

Select SAS

18: Copy the Primary Connection String and secure it in a safe place, as we’ll be using this in the next section when we set up a subscription in commercetools.

SAS Connection String

Set up of our service bus is complete, so feel free to close down your Azure Portal session for now.