Node-RED flows for Microsoft Azure

My blog is about to go dark for two weeks. No new Internet of Ideas articles will be posted until Thursday, September 1, 2016, I take a two-week vacation.

Last post before vacation is about node-Red on Microsoft Azure using local data and Watson APIs. I am a Bluemix guy but I am also in love with node-RED for this reason I am exploring the Azure platform ,  I wanna to test node-RED on Azure cloud and I would like use Watson APIs from Azure to create mashup flows that involve Bluemix and Azure.

First step is necessary to create an Azure Microsoft account, you will have $200 USD in free credits to use however you’d like for a month, you have to provide you credit card as a form of identity validation and verification. With a free account you can build and deploy an app, launch a website or blog, hunt for hidden patterns in your data with Azure Machine Learning, deploy virtual machine and install node-RED 🙂

first step - create an Ubuntu VM
first step – create an Ubuntu VM

First step: Create a virtual machine

Log in to the Azure console, click to add a new virtual machine and select Ubuntu Server. You have to provide the server name, the username for authentication and the size of your instance. I have started with a minimal machine, the node.js is single-threaded so there is no benefit to choose a size with multiple cores for a simple node-red instance, next time I will use the auto-scaling Azure service.

A very import aspect regards the network security group option. I added a new inbound rule:
protocol: TCP
destination port range: 1880

this inbound rule is necessary to route the connections to node-RED instance.

first step - create a Ubuntu VM


Second Step: install Node-RED

Log in Azure virtual machine:

and install Node-RED:

At this point you can test your instance by running node-red:

Once started, you can access to Node-Red flow editor to http://ip_address:1880

Moreover I have installed Watson nodes on Azure Node-RED 🙂 here is the shell command:

and on both Node-REDs (Bluemix and Azure) I have installed Azure IoT Hub, to send IoT data directly to an Azure Hub as an alternative to Watson IoT platform, here is the shell command:

Azure IoT Hub allow to establish bi-directional communication with millions of IoT devices. Rely on Microsoft Azure IoT Hub to easily and securely connect your Internet of Things (IoT) assets. In cloud-to-device messages, reliably send commands and notifications to your connected devices—and track message delivery with acknowledgement receipts.

So, by the Azure console, I have added a new IoT Hub, it is more or less equivalent to our Watson IoT platform:

Azure Internet Of Things
Azure Internet Of Things

To manage the devices connected to the Hub can be very useful to install the Device Explorer application, here is the device explorer download link.

To connect the Device Explorer with the IoT Hub you have to use the connection string provided during the IoT Hub creation, then by the Management tab I created a new device with specific device ID.

For any device created a SAS Token is generated, the token is necessary to connect an IoT device node to the Hub.

Azure IoT device explorer

Any device node in a Node-RED flow have to use a message payload similar to the follow:

you have to provide at least the device ID, the Shared Access Signature Key (often called a token), the protocol type, and the Data, in this simple example I’m sending the ambient temperature using the ESP8266 device, more details here.

Here are the data received by the Azure IoT Hub:

Azure IoT Hub and device explorer
Azure IoT Hub and device explorer

After this bootstrap phase, it’s my first experience with Microsoft Azure environment, I implemented two Node-RED flows:


First Azure node-RED flow

node-RED flow for Azure

I created a Maximo work order from an IoT device. I used the ESP8266 device to monitor a room’s temperature and if the detected temperature is more than 23° Celsius a work order is opened against Maximo. In this scenario I use the Maximo rest API to open a Work Order. Moreover the IoT data are sent from Watson IoT platform to Azure IoT Hub by the specific Azure IoT Hub node.


Second Azure node-RED flow

For the second scenario I used the Weather Company service on Bluemix

Weather Company Bluemix service
Weather Company Bluemix service

and the Weather Company rest API to get the current temperature in a specific location:

Weather Company api

Here is the end to end scenario:

node-RED flow for Azure with IoT Hub - Watson IoT platform - Weather Company api
node-RED flow for Azure with IoT Hub – Watson IoT platform – Weather Company api

I created a Maximo work order from the IoT device as the previous example, but in this case the work order is open if the room temperature is more than 23° Celsius and the external temperature is more than 27° Celsius. The room temperature is sent by the IoT device, the external temperature is temperature provided by the Weather Company API.

so yeah that’s all for the moment, thanks for reading.


Show More

Related Articles

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

HTML Snippets Powered By :