Create Microsoft Azure virtual machines for NGINX Open Source and F5 NGINX Plus

This topic describes how to create Microsoft Azure virtual machines (VMs) to run NGINX Open Source or NGINX Plus.

The names and settings in this document are consistent with Active-Active HA for NGINX Plus on Microsoft Azure Using the Azure Standard Load Balancer, but these VMs can be used for any purpose.

For faster NGINX Plus deployments, you can get a prebuilt VM from the Microsoft Azure Marketplace.

View the Installing NGINX Plus on Microsoft Azure topic for more details.

Before you begin

To complete this guide, you will need the following prerequisites:

If you wish to use NGINX Plus, you will need an NGINX Plus subscription (Paid or trial).

Create a Microsoft Azure virtual machine

To begin, log in to the Microsoft Azure portal.

Then select Virtual machines from the landing page of the Microsoft Azure portal, or the menu in the top-left corner of the page.

The top of the Microsoft Azure portal, showing a row of available services. The second item in the row is Virtual machines option and icon

On the Virtual machines page, select + Add in the upper left corner.

The top of the Virtual machines page, which has a menu of interactive items starting with an Add button

In the Create a virtual machine window that opens, enter the following information on the Basics tab:

Name Value
Subscription NGINX-Plus-HA-subscription
Resource group NGINX-Plus-HA
Virtual machine name ngx-plus-1 (1)
Region (US) West US 2
Availability options No infrastructure redundancy required (2)
Image Ubuntu Server 18.04 LTS
Azure Spot instance No
Size B1s (3)
Authentication type SSH public key
Username nginx_azure
SSH public key source Generate new key pair
Key pair name nginx_key
Public inbound ports Allow selected ports
Select inbound ports (4)
  1. The value ngx-plus-1 is one of the six used for VMs in Active-Active HA for NGINX Plus on Microsoft Azure Using the Azure Standard Load Balancer.
  2. This option is suitable for testing. For production deployments we recommend deploying a copy of each VM in a different Availability Zone.
  3. Select Select size to access the Select a VM size window, choose the B1s row, and press the Select button to return to the Basics tab.
  4. Select SSH (22) and HTTP (80) from the drop-down menu. You should also select HTTPS (443) if you plan to configure NGINX and NGINX Plus for SSL/TLS.
The 'Basics' tab of the 'Create a virtual machine' page, showing the form of parameters to fill

Once you have filled out the information of the Basics tab, select the Networking tab underneath the page heading.

Select Create new below the Public IP field, then select the Standard Radio button under SKU inn the Create public IP address column that opens.

In the Name field, accept the default created by Azure, ngx-plus-1-ip, and confirm it by selecting Ok.

If you are creating VMs to use with Active-Active HA for NGINX Plus, the two VMs must have public IP addresses with SKU type Standard instead of the default Basic.

If you’re creating 6 VMs for Active-Active HA for NGINX Plus, use the following names:

  • ngx-plus-1
  • ngx-plus-2
  • ngx-oss-app1-1
  • ngx-oss-app1-2
  • ngx-oss-app2-1
  • ngx-oss-app2-2

For ngx-plus-2, repeat the previous steps or get a pre built VM from the Microsoft Azure Marketplace).

For the ngx-oss-*, you can create each VM manually or follow the Create an NGINX Open Source image steps to clone additional copies.

The 'Networking' tab of Azure's 'Create a virtual machine' page

Before continuing, there are some values you may wish to change from the default under the Disks, Networking, Management, Advanced, and Tags tabs.

By default, Azure assigns Premium SSD for the OS disk on the disk tab, but you can choose a cheaper option like Standard HDD.

After you’ve completed your changes, select Review + create at the bottom of the Create a virtual machine page.

Your settings will be summarized under the Validation passed banner. Ensure they’re correct, then select Create.

Based on the setting in the Basics tab, a Generate new key pair window will appear. Select Download key and create private resource.

The 'Review + create' tab of the 'Create a virtual machine' page page

The VM deployment will take a few minutes, after which you will see a summary of your resources.

The overview screen of a deployment, showing the resources created during the process

Connect to the virtual machine

To install and configure NGINX Open Source or NGINX Plus on a VM, you will need to connect to the VM with SSH.

Go to the Virtual machines page on the Azure dashboard and click the VM’s name in the Name column of the table.

The 'Virtual machines' page, showing a single item named 'nginx-plus-1'

On the page that opens (ngx-plus-1 in this example), note the VM’s public IP address (In the Public IP address field in the right column).

The page for the 'nginx-plus-1' virtual machine, showing its details

Run this command to confirm an SSH connection to the VM:

ssh -i <private-key-file> <username>@<public-IP-address>
  • <private-key-file> contains the private key paired with the public key you entered in the SSH public key field during Create a Microsoft Azure virtual Machine
  • <username> is the name you entered in the Username field during Create a Microsoft Azure virtual Machine. In this example, it is nginx_azure.
  • <public-IP-address> is the address you found during the previous step.

Install NGINX Open Source or NGINX Plus

After you’ve successfully connected to your Azure VM, you can install NGINX Open Source or NGINX Plus on it.

Install NGINX Open Source or NGINX Plus with Ansible

NGINX provides automatic setup files for Open Source and Plus versions on Ansible Galaxy and GitHub.

The following instructions use the apt package manager, and should be adapted to your operating system.

You should first connect to the virtual machine, then install Ansible:

shell
apt update
apt install python-pip -y
pip install ansible

Once Ansible is installed, you can use ansible-galaxy to install the official Ansible role from NGINX:

ansible-galaxy install nginxinc.nginx
If you are using NGINX Plus, at this stage you should copy the nginx-repo.key and nginx-repo.crt files from MyF5 to ~/.ssh/ngx-certs/.

Create a file called playbook.yml with the following contents:

yaml
---
- hosts: localhost
   become: true
   roles:
      - role: nginxinc.nginx

Then use ansible-playbook to run it:

ansible-playbook playbook.yml

Create an an NGINX Open Source image

If you’ve Installed NGINX Open Source correctly on one VM, you can save it as an Azure template to make additional copies, avoiding the need to follow the full installation process.

Navigate to the Virtual machines page, then select the name of the VM to use as a source image in the list (Named ngx-oss in this example).

On the details page that opens, select the Capture icon in the top navigation bar.

The details page for the 'nginx-oss' VM in Azure

If you use one of the VMs you created in Create a Microsoft Azure virtual machine as the source for the image, you will need to re‑create a VM with that name.

Then edit the following values:

  • Name – Keep the current value.
  • Resource group – Select the appropriate resource group from the drop‑down menu (NGINX-Plus-HA)
  • Automatically delete this virtual machine after creating the image – Yes
  • Zone resiliency – On
  • Type the virtual machine name – Name of the source VM (ngx-oss in this guide)

After reviewing the changed values, select the Create button.

The 'Create image' page for the 'nginx-oss' VM

Create a virtual machine from an NGINX Open Source image

Once the Azure image has been deployed, you can use it to create VMs with NGINX Open Source pre-installed.

Navigate to the Images page of the Microsoft Azure portal.

The 'Images' page of the Microsoft Azure portal

Select the image name in the table, then select + Create VM at the top of the main screen of the next page.

The 'Details' page of the 'nginx-oss-image'

The Create a VM page is identical to the one from Create a Microsoft Azure virtual machine, but will have some pre-filled fields from your image.

For example, the Image field now shows the image name instead of an operating system.

You can continue finishing the VM creation process as normal from here, re-using the image whenever necessary.