4. Azure Service Bus
3 minute read
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
Steps
Companion Video
The companion video for this section can be found here.Create Azure Service Bus
Login to the Azure portal and:
1: Select Create a resource
2: Search for “Azure Service Bus” and select Service Bus by Microsoft:
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
Pricing Tier
We will be using Topics and Subscriptions on the service bus, therefore we need to select the Standard (or above) pricing tier to support this.
At the time of writing, the Basic pricing tier does not support this functionality.
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:
5: When you are happy with the configuration, click Create and Azure will start to provision the service.
Warning
You are provisioning a service that may incur charges borne by the Azure account holder. If in doubt, refer to the Azure Pricing Calculator for more info..6: When the deployment is complete, click Go to resource so that we can set up our Topic:
Create Topic
7: With the newly created service bus namespace selected, click on + Topic:
8: Complete the fields exactly as shown below, and then click Create:
Azure will provision the Topic on the service bus, and you should eventually see: Your topic was successfully completed message:
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:
10: Click on the orders topic that we created in the last section:
11: On the orders topic page, select + Subscription:
12: Complete the name as shown below and click Create when ready:
When Azure has provisioned the Subscription, you should receive a Successfully created Service Bus subscription S1 message:
13: You can further validate the status of the subscription by scrolling down the order topic page:
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:
15: Click + Add:
16: Give your SAS a name, and ensure the Send
permission is selected. When you’re happy, click Create:
Azure will provision the SAS for you, and when completed you should receive the Successfully created SAS policy… message:
17: Select the newly created 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.
Warning
It goes without saying that this connection string should not be published anywhere as it grants the holder permission to publish onto your service bus topic.Set up of our service bus is complete, so feel free to close down your Azure Portal session for now.