Azure Virtual Machines Demystified: Installing NGINX Web Server

Abhinav Virpal Singh
11 min readSep 8, 2023

In today’s digital landscape, cloud computing has become the backbone of modern IT infrastructure. Microsoft Azure, one of the leading cloud platforms, offers powerful tools and services for deploying and managing virtual machines (VMs). This blog provides a comprehensive, step-by-step guide to deploying an Azure VM and setting up an NGINX web server, a fundamental skill for anyone venturing into cloud-based web hosting.

Azure’s user-friendly interface and robust features make it an ideal choice for both beginners and experienced cloud enthusiasts. I walk you through each crucial step, from selecting VM specifications to configuring network settings and securing your resources.

By the end of this tutorial, you’ll have a fully operational Azure VM running an NGINX web server, accessible from anywhere. Whether you’re looking to host a personal website, launch a web application, or simply explore Azure’s capabilities, this guide will equip you with the knowledge and skills to get started. Join us on this journey into the cloud, and let’s deploy your first Azure VM together.

Step 1: Go to Azure Portal and click on Virtual Machines and then click on Add.

Step 2: Now you will be on the Basics tab. Here you will need to fill in the following details:

  • Subscription: Select the subscription you want to use for this VM.
  • Resource group: Select the resource group you want to use for this VM.
  • Virtual machine name: Enter a name for your VM. Here we will be using as Test_VM.
  • Region: Select the region you want to use for this VM. Here we will be deploying in East US.
  • Availability options: Select the availability options you want to use for this VM. Here we will be using as No infrastructure redundancy required.
  • Security Type: Select the security type you want to use for this VM. Here we will be using Standard.
  • Image: Select the image you want to use for this VM. Here we will be using Ubuntu Minimal 22.04 LTS.
  • VM Architecture: Select the VM architecture you want to use for this VM. Here we will be using x64.
  • Size: Select the size you want to use for this VM. Here we will be using Standard_B1s.
  • Username: Enter a username for your VM. Here we will be using as azure_user.
  • SSH public key source: Select the SSH public key source you want to use for this VM. Here we will be using as Generate new key pair.
  • Key pair name: Enter a key pair name for your VM. Here we will be using as azure_key.
  • Public inbound ports: Select the public inbound ports you want to use for this VM. Here we will be using as Allow selected ports.
  • Select inbound ports: Select the inbound ports you want to use for this VM. Here we will be using as SSH (22), HTTP (80), HTTPS (443).

Step 3: Now you will be on the Disks tab, Here you will need to fill in the following details related to the disks:

VM Disk Encryption

  • Encryption at the host: Select the encryption at the host you want to use for this VM. This option enables the encryption for the temporary disks and ephemeral OS disks with the platform managed keys Here we will be using as Disabled.

OS Disk

  • OS Disk Size: Select the OS disk size you want to use for this VM. Here we will be going with the Resize to 32 GiB (P4).
  • OS Disk Type: Select the OS disk type here we will be going with Standard SSD. (Locally Redudant Storage)
  • Delete with VM: Select this checkbox if you want to delete the created drive at the time of VM deletion.
  • Key Management: Select the key management as Platform managed key. This will be used to encrypt the OS disk.

Data Disk for the TestVM

As we don’t have any data disk prior to this, we will be adding a new data disk to the VM. So for this we will be going ahead with the Create and attach a new disk option.

  • Name: Enter a name for your data disk. Here we will be using as TestVM_DataDisk.
  • Source Type: This option allows you to configure your data disk as Snapshot, Storage blob, or None (Empty Disk). Here we will be using as None (Empty Disk) as we dont have any data disk prior to this.
  • Size: This option determines the size of the data disk. Here we will be using as 32 GiB with Standard SSD (Locally Redudant Storage).
  • Key Management: Select the key management as Platform managed key. This will be used to encrypt the data disk.
  • Enable Shared Disk: Enable this option if you want to use the disk as a shared disk with other VMs as well. Here we will be using as Disabled.
  • Delete Disk with VM: Select this checkbox if you want to delete the created drive at the time of VM deletion. Here we will be checking this as Enabled.

Advanced

  • Use managed Disks: Select this checkbox if you want to use managed disks for your VM. Here we will be using as Enabled.
  • Ephemeral OS disk: Select this checkbox if you want to use ephemeral OS disk for your VM. Here we will be using as None.

Step 4: Now you will be on the Networking tab, Here you will need to fill in the following details related to the networking:

Network Interface

  • Virtual Network: This is the virtual network that will be used for the VM. Here we will be using as TestVM-vnet.
  • Subnet: This is the subnet that will be used for the VM. This will be the default subnet as (10.0.0.0/24).
  • Public IP: This is the public IP that will be used for the VM. Here we will be using as TestVM-ip.
  • NIC network security group: The NSG is a set of security rules that allow or deny any of the inbound or outbound traffic for the VM. Here we will be using the basic one.
  • Public Inbound Ports: This is the public inbound ports that will be used for the VM. Here we will be using as Allow selected ports.
  • Select Inbound Ports: This is the inbound ports that will be used for the VM. Here we will be using as SSH (22), HTTP (80), HTTPS (443).
  • Delete public IP and NIC when VM is delete: Select this checkbox if you want to delete the created public IP and NIC at the time of VM deletion. Here we will be using as Enabled.

Load Balancing

This shows you the option for placing your VM in a back-end load balancer pool. Here we will be using as None.

  • Place this virtual machine behind an existing load balancing solution: We will be leave it unchecked this as we will be using as None.

Step 5: Now you will be on the Management tab, Here you will need to fill in the following details related to the management:

Microsoft Defender for Cloud

It is a cloud-based security service that helps you protect your organization’s data and endpoints against cyberthreats.

Identity

  • Enable system assigned managed identity: This is a system assigned managed identity that enables the authentication to the cloud services without storing the credentials in the code. Here we will be using as Enabled.

Azure AD

  • Login with Azure AD: This is the Azure AD feature that enables the authentication to the VM, enforcing MFA and enabling RBAC. Here we will be using as Enabled.

Auto-shutdown

This features enables the auto-shutdown of the VM at a specific time. Here we will be using as Disabled.

Backup

This feature enables the backup of the VM. Here we will be using as Disabled.

Guest OS Updates

  • Patch Orchestration Options: This feature enables the patch orchestration options for the VM. Here we will be using as Image-Default.

Step 6: Now you will be on the Monitoring tab where you can enable the monitoring for the VM.

Alerts

This feature enables the alerts for the VM.

  • Enable recommended alert rules: This feature enables the recommended alert rules for the VM. Here we will be using as Disabled.

Diagnostics

This feature enables the diagnostics for the VM.

  • Boot Diagnostic: This is a feature for the VM to troubleshoot the boot failures and this also improved the creation time of the virtual machine. Here we will be Enable with managed storage account.
  • Enable OS guest Diagnostics: It is more like of a monitoring feature that enables the monitoring of the VM. Here we will be using as Disabled.

Step 7: Now you will be on the Advaned tab where you can enable the advanced features for the VM.

Extensions

This feature enables the extensions for the VM, this helps in the post deployment configuration of the VM.

  • Extensions: Here we will not be using any of the extensions here.

VM applications

This feature allows you to install the applications on the VM at the time of deployment.

Custom data and cloud init

This feature allows you to run the custom scripts at the time of deployment. You can also add other data while the process of provisioning the VM.

  • Custom data: Here we will be using as None.

User Data

If you want to keep your Azure Resources physically closer to each other, you can enable this feature.

This feature allows you to have your data available on the VM at the time of deployment.

Performance (NVMe)

This feature allows you to have the NVMe disk for the VM and boost the performance of the VM.

Host

If you want to manage the host for the VM, you can enable this feature.

Capacity reservations

This feature allows you to reserve the capacity for the VM.

Proximity placement groups

If you want to keep your Azure Resources physically closer to each other, you can enable this feature.

Step 8: Now you will be on the Tags tab where you can add the tags for the VM. These tag will help you in the billing and the management of the VM. If you create tags and change their assignments, you can use the tags to filter the view of your resources in the portal.

Step 9: At this step you will be on the Review + create tab. Here you can review all the settings that you have configured for the VM. If you want to make any changes, you can go back to the respective tab and make the changes. If you are satisfied with the settings, you can click on the Create button to create the VM.

Step 10: As you will create the VM you will see a pop-up to Generate the key pair. As you will click on download and create resources it will download a PEM file.

Step 11: Here you can see that the VM is being created and other resources with it are created as well.

Step 12: As the VM is created you can see the overview of the VM.

Now, you can connect to the VM using the SSH key pair that you have downloaded or the connect page from the VM.

Step 13: Now we will connect the VM using our local machine using the Azure CLI which is installed on our local machine.

az login

Enter this command to login to your Azure account, when you enter this command you will see a pop-up to login to your Azure account. Enter the credentials and login to your Azure account.

Step 14: Before connecting to your created VM you need to make your VM SSH ready, for which azure comes with all the pre-requisites installed on the VM to connect to it. This process lets you enable the port 22 on the VM with the Just in Time policy of the VM.

Step 15: Now, you will need to enter the following command to connect to the VM.

az ssh vm --ip <PublicIPAddress>

Here you will need to enter the IP address of your VM. As you will enter this command you will see a pop-up to enter the SSH key pair. Enter the path of the PEM file that you have downloaded and enter the passphrase for the PEM file. Here it will ask you to install an extension ssh to connect to the VM. Enter y to install the extension.

Step 16: Now, We will just update the VM.

sudo apt-get -y update

Installing nginx web-server

Step 17: Now, we will be installing NGINX web server on the VM.

sudo apt-get -y install nginx

Step 18: Now, we will check the status of the NGINX web server.

sudo systemctl status nginx

Step 19: Now, we will check the status of the NGINX web server on the browser.

http://<PUBLIC IP ADDRESS>/

Step 20: We can also check the status of the NGINX web server on the Azure portal.

curl -m 80 <PublicIPAddress>
Keep Learning!!! Keep Growing!!!

--

--

Abhinav Virpal Singh

MCT || Multi-Cloud & DevOps Enthusiast || Multi-Cloud Learner || Opportunity Seeker || Azure(x6) || Alibaba Cloud(x2) || CJE