Install Node-RED on a virtual machine

This guide walks you through the steps of running Node-RED on an Azure virtual machine instance.

Create a base image

Log in to the Azure console

Click to add a new… virtual machine

In the list of virtual machines, select Embedded Linux Server and click Create

Give your machine a name, the username you want to use, and the authentication details you want to use to access the instance

Choose the size of your instance. Keep in mind that node.js is single-threaded, so there is no benefit in choosing a size with multiple cores for a simple node-red instance. A1 Basic is a great starting point

In the Settings step, click on the Network Security Group option. Add a new “Inbound Rule” with options set to:

Name: node-red-editor

Priority: 1010

Protocol:TCP

Destination port range: 1880

Click OK on the settings page, review the summary, and click OK to deploy the new instance

After a few minutes, your instance will be running.In the console you can find the IP address of your instance

Definir Nó-RED

A próxima tarefa é fazer login na instância e instalar o node.js e o Node-RED.

Log in to your instance using the authentication details you specified in the previous stage.

Depois de iniciar sessão, é necessário instalar o node.js e o Node-RED

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

sudo apt-get install -y nodejs build-essential

sudo npm install -g -unsafe-perm node-red

Neste ponto, você pode testar sua instância executando node-red. NOTA: Poderá receber alguns erros relativos a nós em série - isto é esperado e pode ser ignorado.

Uma vez iniciado, pode iniciar sessão em http:// :1880/.

Para que o Node-RED seja iniciado automaticamente quando sua instância for reiniciada, você pode usar o pm2:

sudo npm install -g -unsafe-perm pm2

pm2 start `que nó-vermelho` - -v

pm2 guardar

arranque do pm2

NOTA: Este último comando irá pedir-lhe para executar outro comando - certifique-se de que faz o que ele diz.

Palavras-chave: Gateway LoRa