AMQP to Azure Service Bus with Linux


IoT Scenario: AMQP to Azure Service Bus

In this post I’ll create message communication from a Linux CentOS VM with AMQP to Azure Service Bus. I chose Linux because it is on a lot of IoT related devices. I’ll describe a few steps to make it work:

  1. Create the Service Bus on Microsoft Azure
  2. Create a Linux VM on Microsoft Azure
  3. Connect to the VM via SSH
  4. Install Apache Qpid Proton-C on the VM
  5. Create a Python script to send the message
  6. Create the Service Bus on Microsoft Azure

When you create a Service Bus via the Azure portal it is not possible to use ACS. But for the AMQP communication you need ACS, so you can create a Service Bus with Powershell.

If you don’t have Azure Powershell download and install it first.

Open the Microsoft Azure Powershell window and run this command:

azure-1 Get PubSettings File

It will bring you to a webpage where you can download your .pubsettings file. Login with your Azure credentials and choose the subscription where you want to create the Service Bus.

Download PubSettings File

Then run the command to import the .pubsettings file you just saved:

1Import-AzurePublishSettingsFile “location path .pubsettings file”
azue-2 Import PubSettings File


Now you are connected to the Azure subscription and ready to create the Service Bus with ACS:

1New-AzureSBNamespace chris-amqp-ns -Location “West Europe” -CreateACSNamespace $true -NamespaceType Messaging
Azure-3 Create Service Bus


Remember that ACS is needed for this scenario, so the parameter -CreateACSNamespace is $true. In the Azure Portal the new Service Bus is visible.

azure5 Service Bus on Azure Portal

Next you can create a queue to which the messages will be send. In the Azure Portal, use the Custom Create, because you have to disable partitioning wich is enabled by default.

azure-7 Create Queue on Azure PortalDisable Partitioning Queue


That’s it, the Service Bus is ready!

  1. Create a Linux VM on Microsoft Azure

The next step is to create a VM on Azure. Go to the Azure portal and create a new VM from Gallery.

azure-9 Create VM on Azure Portal

Check the ‘Provide a password’ checkbox. You’ll need the username and password for the SSH connection in step 3.

azure-10 Create VM User on Azure Portal

Keep the defaults in the next two steps and create the VM.

  1. Connect to the VM via SSH

For the SSH connection I’ll use Putty. Other SSH client should also work. Find the DNS name and SSH portnumber of the created VM in the Azure portal. Fill these settings in Putty.

azure-11 Putty Configuration

Click Open to open the connection. Then fill the credentials you used when the VM was created.


  1. Install Apache Qpid Proton-C on the VM

The next step is to install Apache Qpid Proton-C. First you have to install a few packages. Run this command:

1sudo yum install gcc cmake libuuid-devel


azure-13 Install Packages on VM

Then run this command, for SSL support:

1sudo yum install openssl-devel

Next run the command to install dependencies for binding:

1sudo yum install swig python-devel ruby-devel php-devel java-1.6.0-openjdk

You’ll also need dependencies for python docs:

1sudo yum install epydoc

Install wget so files can retrieved from the internet:

1sudo yum install wget

Now you can download Qpid Proton:

1sudo wget

And extract the files:

1sudo tar xvfz qpid-proton-0.8.tar.gz

You can find a directory named ‘qpid-proton-0.8’ when you use dir or ls. Change the directory to ‘qpid-proton-0.8’:

Show Qpid Directory

Now create a new directory named ‘build’ and change the directory to that new folder:

1mkdir build
1cd build

Build and install the code using the following commands:



1sudo make all docs


1sudo make install
  1. Create a Python script to send the message

Finally, the last step! You are ready to create the script that will send a message to the Azure Service Bus. First change your directory to home/{username}/. Thats the directory with ‘qpid-proton-0.8’.


HomeUsername Directory

Now create a new directory for the python script, and change the directory to that new folder:

1sudo mkdir pythonscripts
1cd pythonscripts

Create the script, I’ll use vi, but you can use the editor you want:

1sudo vi

Paste this script in the created file:













import sys, optparse

from proton import *


messenger = Messenger()

message = Message()

message.address = “amqps://{ISSUER}:{KEY}@{servicebus namespace}{queuename}”


message.body = u”This is a text string”


print(“***BEGIN SEND***”)


print(“***END SEND***”)

Fill the correct settings in the amqp address. For this blog it is “amqps://owner:{KEY}”
You can find the key in the Azure portal. There is a botton ‘connection information’ at the bottom of the Service Bus page. When you click that button you can find the key and the issuer.


Access Service Bus

Now, run the sender. First check your queue:


Queue Before Running Script

Run the script:

1python ./


Run The Script

And check the queue in the Azure portal. There should be one message more then before you ran the script.


Queue After Running Script


We created a Linux VM and a Service Bus on Microsoft Azure. We installed Apache Qpid Proton-C on the VM to send an AMQP message to the Service Bus.
Linux and AMQP are used a lot in IoT scenarios, but not everyone has devices to test AMQP messages. The scenario in this blog can be achieved with just an Azure subscription.
The next step is to install linux on a board like Galileo and send messages to the Azure Service Bus. Soon I’ll show how you can do that.

Originally published on

Chris Arend


The vision of Chris is that technology should be supportive and, if possible, in the background. We should not use our energy to adapt (new) technology. Technology should adopt us and should be able to connect with us in a way that we connect to other people. Technology should become our digital friend. This will minimize the negative side effects that we see with technology like social media and smartphones. This will make us happy on a longer term. Conversational solutions are a great tool to service this goal. They are able to speak, see and understand like we do. With chatbots and voicebots, we make a great step forward to an environment where technology adopt our behavior instead of the other way around. Chris is a leader in conversational strategy. He is able to close the gap between new technology and a company's vision. With his technical background, he is able to show the real value of new technology and make it work!

More on Chris Arend.

Related Posts

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