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:

1 Get-AzurePublishSettingsFile
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:

1 Import-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:

1 New-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:

1 sudo yum install gcc cmake libuuid-devel


azure-13 Install Packages on VM

Then run this command, for SSL support:

1 sudo yum install openssl-devel

Next run the command to install dependencies for binding:

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

You’ll also need dependencies for python docs:

1 sudo yum install epydoc

Install wget so files can retrieved from the internet:

1 sudo yum install wget

Now you can download Qpid Proton:

1 sudo wget

And extract the files:

1 sudo 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:

1 mkdir build
1 cd build

Build and install the code using the following commands:



1 sudo make all docs


1 sudo 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:

1 sudo mkdir pythonscripts
1 cd pythonscripts

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

1 sudo 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:

1 python ./


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


Chris is a vibrant professional with thorough knowledge on connecting things. He has an open mindset and go-get mindset and way of working. With this enthusiasm he has been able to move Sogeti NL professionals to get hands on with IoT during the IoT Battle where he was one of the initiators. He lives and breathes innovation around IoT and has had huge influence in shaping solution for clients, most notably a mobile app for an energy company and Tesla. With his interest and expertise of connecting things and people he will drive many IoT and other high impact and visible projects in the future and take our Labs Community steps further along this path.

More on Chris Arend.

Related Posts

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

6 + 2 =