node package manager



Communicate with Azure IoT Hub from any device over AMQP.

npm version


npm install -g azure-iot-device-amqp@latest to get the latest (pre-release) version.

Getting Started

Create a device client:

var clientFromConnectionString = require('azure-iot-device-amqp').clientFromConnectionString;
var Message = require('azure-iot-device').Message;
var connectionString = '[IoT Hub device connection string]';
var client = clientFromConnectionString(connectionString);

Create a callback that sends a message and receives messages. When it receives a message it sends an acknowledgement receipt to the server:

var connectCallback = function (err) {
  if (err) {
    console.error('Could not connect: ' + err);
  } else {
    console.log('Client connected');
    var message = new Message('some data from my device');
    client.sendEvent(message, function (err) {
      if (err) console.log(err.toString());
    client.on('message', function (msg) { 
      client.complete(msg, function () {

Open the connection and invoke the callback:;