RabbitMQ on Microsoft Azure

By: on May 28, 2015

With 10,000 new customers each week, Microsoft Azure is one of the major cloud platforms allowing to deploy various services including web applications and virtual machines. RabbitMQ can already be installed on an Amazon EC2 platform or ran as a service on Heroku with Bigwig. In this post, we are going to go through all the steps required to run a RabbitMQ server on a Microsoft Azure virtual machine and access it remotely.

Choose your virtual machine

The first step is to choose which system to install RabbitMQ on. We recommend the easiest installation which is the Linux one but RabbitMQ can of course also be installed on Windows.

Install RabbitMQ

Once the virtual machine is installed, use the public virtual IP address or the DNS name to connect to the VM via SSH for a Linux installation or via Remote Desktop Connection for a Windows installation.

Regarding the installation, you can follow these instructions for Windows or these instructions for Linux.

After the installation, the RabbitMQ server should start automatically.

Activate the management interface

You can manage RabbitMQ in a terminal window on Linux or on the RabbitMQ Command Prompt on Windows which opens a Command Prompt in the RabbitMQ installation directory.

On Linux, all management commands need to be run as a superuser. On Windows, the RabbitMQ Command Prompt should already be in administrator mode. Commands are available as .bat scripts. To simplify, we will just write here the command names.

RabbitMQ comes with a management interface that enables to manage the broker very easily from a web page with user access. In order to enable this interface run the following command on the VM:

rabbitmq-plugins enable rabbitmq-management

After doing that, the RabbitMQ server needs to be restarted.

On Linux, you can use the service command to do that:

service rabbitmq-server restart

On Windows, launch the following services in this order:

rabbitmq-service.bat stop
rabbitmq-service.bat install
rabbitmq-service.bat start

Please see the following page for more information on the management interface: http://www.rabbitmq.com/management.html

Remote access

In order to secure the remote access to the management interface, you will need to change the guest user password. It is also recommended to create another user (and assign the right permissions to it).
To do that, we use rabbitmqctl which is a tool that allows to configure RabbitMQ via a command line interface:

# Change guest password
rabbitmqctl change_password guest new_password

# Add a new user
rabbitmqctl add_user user_name password
rabbitmqctl set_permissions -p vhost user_name “.*” “.*” “.*” # set config/write/read permissions 
rabbitmqctl set_user_tags user_name administrator # assigns administrator tag

See http://www.rabbitmq.com/access-control.html for more information.

To establish a remote connection to the broker, you will need to add endpoints to your virtual machine settings.
Microsoft Azure endpoints are a way to define what protocol and ports are exposed to the outside world.
You define a protocol and a private and public ports. The public port is the one that the service is listening on the outside. The private port is the one that the service is listening on internally.

The management interface is available on port 15672 and the broker listens to connections on port 5672.

Endpoints can be added on the Azure web interface but it is simpler to do it remotely on a command line. You can install the Azure CLI tool on your local machine for this purpose. Click here to see installation instructions for both Linux and Windows.

Before running any Azure CLI commands you will need to authenticate. To do that, run:

azure account download

It will show you a link that you should open in your browser (the browser should be launched automatically on Windows). You will be able to download an authentication file (with extension .publishsettings) that you must then import:

azure account import downloaded_file

Then, add the required endpoints using the virtual public IP address:

azure vm endpoint create your-vm-name 15672 # creates a TCP endpoint on port 15672 to enable access to the management interface

azure vm endpoint create your-vm-name 5672 # creates a TCP endpoint on port 5672 to enable connections to the broker

(Here, public and private ports are the same)

To see the created endpoints, the following command can be used:

azure vm endpoint show your-vm-name

For a Windows VM, an extra step is required because the Windows Firewall might block communication through these ports. See this page on how to add firewall rules on your VM to open these ports.

You should now be able to connect to RabbitMQ management console on http://your-vm-ip:15672 and to use the virtual machine as the broker in your RabbitMQ program.

Share

Comment

  1. Duncan says:

    Thanks for taking the time to write thsi up. It has helped me and I am sure alot more people worldwide.

    Just FYI, the command “rabbitmq-plugins enable rabbitmq-management” returns -> Error: The following plugins could not be found: rabbitmq-management. (Windows Server 2012 Azure VM)

    I noted that the hyphen should be an underscore, as in “rabbitmq_management”

    The command “rabbitmq-plugins enable rabbitmq_management” returns -> The following plugins have been enabled:
    amqp_client
    cowlib
    cowboy
    rabbitmq_web_dispatch
    rabbitmq_management_agent
    rabbitmq_management

    \o/ great success!

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*