DEV Community

Ojeniran Shola
Ojeniran Shola

Posted on

How to setup Azure Virtual Machine

This Blog is about how to setup your Azure virtual Machine on Azure, connect to the virtual Machine via SSH (Secure Shell Host), install Apache 2 (as web server) and access the VM (virtual machine) IP via a browser.

Virtual Machines are cloud based computers where most servers in the world are hosted due to its cost effectiveness and easy scalability.

This is a simple setup on how to setup a virtual machine on Azure:

  1. Create a Resource Group
  2. Create a VNet (Virtual Network) in the newly created Resource Group. Ensure the Vnet carries a /16 private IP Address.
  3. Create a subnet inside the VNet with a /24 IP address.
  4. Create a Virtual Machine inside the newly created subnet through these simple steps:

a. Ensure the newly created resource group is selected for the new virtual machine. Create a new name for the virtual machine and a region.

Fig 1

b. Select Zone, OS Image, and disk size/type

Fig 2

c. Under authentication type, select "SSH public key", create a username, and key pair name

Fig 3

d. Enable inbound port (port 22 for SSH and port 80 for HTTP) for the purpose of this blog, and click on next

Fig 4

e. Under the Disks tab, make sure the default is selected (image disk 30gb) and click on next (to networking tab)

Fig 5

f. Under the networking tab, ensure the newly created VNet is selected. Select "Basic" for NIC network security group and make sure port 80 (http) and port 22 (SSH) are selected on the inbound port field.

Fig 6

Fig 7

g. Under Review and create, ensure all validations are passed. Click on "create" to open the "download SSH key pair" box for download

Fig 8

Fig 9

Fig 10

5 Once the virtual machine is created, azure displays a status page to view all the features of the newly created vm.

Fig 11

6 Open GIT Bash terminal.
Change directory to where the ssh key was downloaded (the downloads folder in this case by using this command : cd Downloads
Log on to the virtual machine using this linux command: ssh -i demovm_key.pem azureuser@172.209.216.195
Syntax: ssh -i ssh-key-filename.pem vm-username@vn-public-ip(as seen on the status page)

Fig 12

7 Install the Apache2 web server using the linux command: sudo apt install Apache2

Fig 13

8 Once installation is completed, open your browser and type the public IP as seen on the vm status page. In this case, the public IP is 172.209.216.195 and you will see an Apache 2 successful page.

Fig 14

With these simple steps, you have successfully created a virtual machine on Azure, created a SSH authentication login and used GIT bash and linux commands to logon into your vm and installed a web server.

Top comments (0)