Creating and running a NEO Node on Microsoft Azure in under 30 minutes

Alex Guba
8 min readFeb 25, 2018

--

The NEO blockchain is rapidly growing, and with that growth comes increased network demands on the infrastructure and protocol. To this end, as a community we can help NEO grow as a stable and performant platform by running seed nodes (this is not the same as Consensus Nodes, which have their own standards and voting process). Mainnet seed nodes will simply help add bandwidth, stability and performance to the NEO Blockchain.

Create a Microsoft Azure Account

Go create a an account at https://azure.microsoft.com to get started.

Note: Azure is currently offering free trial accounts for 30 days with a $200 spend limit: https://azure.microsoft.com/en-us/offers/ms-azr-0044p/. For around $75 a month, you can put up a single NEO node (every node counts), so with that free account, you could easily run 2 nodes for free for 30 days to help the NEO blockchain.

Create a Virtual Machine

You could also create a Windows based VM, but the cost is substantially higher and unnecessary for running a NEO Node. So for this example, we will create an Ubuntu Server 16.04 VM.

Choose to Install a VM Running Ubuntu Server 16.04
1. Click on All Resources or Virtual Machines from the left pane
2. Click +Add at the top
3. Choose to install Ubuntu Server 16.04 VM from the Azure Marketplace

Creating a SSH Key
If you don’t already have a SSH key, this is far more secure than a password for multiple purposes(Git, FTP, SSH, etc).

If you don’t know how to create a SSH key, read here:
https://docs.microsoft.com/en-us/azure/virtual-machines/linux/create-ssh-keys-detailed

If you are going to use PuTTY to connect, it’s a little different:
https://www.digitalocean.com/community/tutorials/how-to-create-ssh-keys-with-putty-to-connect-to-a-vps

Set the Basics for your new VM
Set the name, disk type, whether you want to SSH with a public key or use a password (SSH key is the preferred method as it’s more secure), the resource group this VM will run under (for billing), and finally the location of the datacenter this VM will be running from.

Select the size of the VM you want to install
There are a variety of configurations you will be able to install, it seems that a D3S_v3 with 2 CPU cores and 8GB ram is the minimum configuration for a NEO Node.

Set the firewall rules to allow incoming RPC traffic
We can do this in the VM settings, Network Sescurity Group (firewall), and create a new group for our VM.

Allow Inbound Requests for NEO RPC
After we create the group, we need to add an inbound rule to allow requests coming in on ports 10331–10334, 20331–20334

Review and Create
Review the settings summary of the VM, and click to Create.

Connecting to the Virtual Machine

Get the IP or Domain Name to access the Virtual Machine
Watch your notifications and VM list to check on the status of your VM deployment. Once it is running, choose it from the menu to see the details and find the IP of your created VM. Optionally you can access this VM by a Domain Name as well, but you will need to configure this manually.

Update: For nodes to be listed on the City of Zion NEO Monitor, you must use a FQDN, IP addresses are no longer allowed.

Create a Fully Qualified Domain Name to your Node
If you want to use a Domain Name to access the node instead of just the IP, you can easily configure one by going to the Public IP Address configuration for your VM and defining the Domain Name to use.

Note: If you are going to list your node on the CoZ Mainnet NEO Monitor, it is required that you use a FQDN.

If you want to use your own domain name to point to this node instead of the Azure defined FQDN, you can just create a CNAME record in your DNS that points to this FQDN in azure.

So, if you wanted to have neonode1.yourdomain.com, you would simply add a CNAME record like this (interface shown is GoDaddy):

SSH to the Virtual Machine
You will need a SSH Client. On Linux and OSX, SSH usually comes as a standard installed package from the command line, on Windows you can download and install PuTTY from: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Once you have a SSH client installed, SSH to the IP or FQDN of the Virtual Machine you just created.

Configure the Virtual Machine

Once you have successfully logged into your VM via SSH, you will need to install the dependencies for neo-cli (leveldb, sqlite, dotnet).

Update: Since .NET Core is static linked from the neo-cli project, you should not need to install the .NET core. If you end up needing it, instructions on installing .NET Core on Ubuntu 16.04 can be found here: https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x

Install Prerequisites and neo-cli (version 2.7.3 at current)

> sudo apt-get install unzip libleveldb-dev sqlite3 libsqlite3-dev libunwind8-dev

> wget https://github.com/neo-project/neo-cli/releases/download/v2.7.3/neo-cli-ubuntu.16.04-x64.zip

> unzip neo-cli-ubuntu.16.04-x64.zip

Bootstrap your Node

It can take a long time to sync the entire mainnet blockchain, but you can download a bootstrap zip that will considerably decrease your sync time by downloading the blockchain files directly instead of trying to sync them actively from other nodes (this will also reduce load from the network). Always check here for the latest available bootstrap files
https://github.com/CityOfZion/awesome-neo

To bootstrap your node, download the latest S3 bootstrap file (latest as of 3/15/18 to accommodate mainnet upgrades):

> wget https://s3.eu-west-2.amazonaws.com/ashant-neo/chain.acc.zip

And unzip the contents to your neo-cli folder

> unzip chain.acc.zip -d ./neo-cli/

Start the Node and Confirm it is Running

To start neo-cli:

> cd neo-cli
> dotnet neo-cli.dll /rpc

After you see the neo> prompt, send a HTTP POST request to the node you just created from your client machine to make sure the node is running and that your firewall is set up correctly to receive inbound requests. You can simply use curl to send HTTP requests to your running node:

> curl -X POST \
http://<IP of your node>:<RPC port of your node>\
-H ‘Content-Type: application/json’ \
-d ‘{ “jsonrpc”: “2.0”, “id”: 5, “method”: “getversion”, “params”: [] }’

On OSX or Linux, curl should be installed, but on you can either simply install curl for Windows here, or you could also run a light instance of Ubuntu on Windows as outlined in the “Installing the Windows Subsystem for Linux” section in this article.

Another nice option is using the Advanced REST Client Chrome Extension for testing HTTP requests:

If your node is running, you should receive a return value that contains something like this:

{
“jsonrpc”: “2.0”,
“id”: 5,
“result”: {
“port”: 10333,
“nonce”: 1215806116,
“useragent”: “/NEO:2.7.1/”}
}

It will take a little bit for the remaining blocks to sync even though we bootstrapped, you can check the status of the node by using the commands “show state” and “show node”.

Now that we know the node works, we’ve got to exit and make sure it can restart itself and run after we leave the SSH session.

Type “exit” to shut the node down.

Install a Supervisor

You also need to makes sure that the process keeps running if you close the SSH window or if there is an unexpected system reboot. The correct way to do this is to use a supervisor, we are going to systemd that is standard with Ubuntu:

First we need to create the service config file and edit it:

> cd /etc/systemd/system
> sudo vi neoseed.service

The contents of your config file should be something like this:

(thanks to @metachris for helping in getting the systemd config files together and sharing his configuration)

[Unit]
After=network-online.target
Requires=network-online.target

[Service]
WorkingDirectory=/home/<your_username>/neo-cli
ExecStart=/usr/bin/dotnet neo-cli.dll /rpc
ExecStop=kill -SIGINT `ps ax | grep neo-cli | grep -v grep | awk ‘{print $1}’`
Restart=always
StandardInput=tty-force
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=neoseed
User=<your_username>
Group=<your_username>

[Install]
WantedBy=multi-user.target

When done editing, Hit ESC to go to command mode, and type :x to save.

Now we need to enable the service

> sudo systemctl enable neoseed
> sudo systemctl start neoseed

And let’s make sure it started successfully

> systemctl status neoseed

(For future reference) the commands to manage nanoseed are:
> systemctl status neoseed
> sudo systemctl start neoseed
> sudo systemctl stop neoseed

Register the Node to the Network Status Monitor

City of Zion has a nice network monitoring web interface that will monitor all of the seed nodes that are reported. Once you have confirmed that your node is running, report it to the network status monitor via the neo-mon project.

Note: CoZ wants to guarantee that any seed node listed on the NEO Monitor page are not attackers. All seed nodes wishing to be included must be a part of a project, and need to gain prior approval from CoZ in order to to be listed.

To report your running node(s):

  1. Fork and clone the neo-mon project
  2. Edit the mainnet node list:

<your neo-mon checkout folder>/src/assets/json/mainnet.json

  1. Add your node to the array of nodes in the following format:

{
“protocol”: “http”,
“url”: “<IP or FQDN of your Node>”,
“location”: “USA”,
“locale”: “us”,
“port”: “<RPC port of your node>”,
“type”: “RPC”
}

  1. Commit your changes to your forked repo master
  2. Create a pull request to the https://github.com/CityOfZion/neo-mon project for your changes.

And that’s it! You are now running a full NEO Node running on Microsoft Azure, and helping the NEO Smart Economy get stronger!

Need additional help?

City of Zion
If you need further assistance in getting started, feel free to join the City of Zion NEO Smart Economy Discord Server. The community will help you get set up in no time.

--

--