Introduction
This is the first installment of a two-part post focused on creating a Linux virtual machine with Azure. If you have been following my journey into cloud development, I have written about setting up a Windows virtual machine in Azure too.
Two authentication approaches can be used to set up the Linux virtual machine. This post will focus on one which is the password authentication
As I have suggested in previous posts about setting up virtual machines, having a Microsoft and an Azure account is a prerequisite for following the steps in this post.
Step 1: Create a Linux Virtual Machine
- Click the + Create icon at the top of the page or click the Create button at the bottom to create a virtual machine.
Basics Tab
- Under Project details, name the Resource Group or choose a Resource Group
- Next, give the Virtual Machine a name.
For the Availability Options label, select Availability zone.
- At the Availability zone label, select zone 2 (I selected zone 2 in mine. However it may be different in yours).
- Security type label should be set at Trusted launch Virtual Machines
- The Image label should be set to Ubuntu Server 22.04 LTS x64 Gen2
Do not tick Enable Hibernation box as well.
- Under Administrator Account heading, Set Authentication type to Password. I will handle SSH Authentication in part two of this post.
- Set Username, Password and confirm Password subsequently.
At Public inbound ports label, select Allow selected ports, and
for the Select inbound ports label, at the dropdown, tick HTTP (80) and SSH (22). HTTP was selected as part of the ports because I will access the server via a browser at some point in this post.
Monitoring Tab
- Click Monitoring at the top of the page
- Click Disable to disable diagnostics. This is to prevent third-party access.
Tags Tab
- Under the Tag Tab it is ideal that name and value are created for the resources. Give the resource a name and value In the annotated part of the image below. They help to categorize resources. Both the name and value are called Tags.
Click the Review + create tab or the Review + create button at the bottom of the page.
Click the Create button to complete the configuration process.
After the complete deployment, click the go to resources button. This completes the creation of the virtual machine.
The next thing to do is to increase IP address timeout to prevent untimely shutdown.
At the Virtual Machine overview page, click on the IP address at the IP address label
This re-directs to an IP configuration page. While on the page move the idle timeout slide to the right hand of the page.
- Click the Save icon at the top of the page.
- Close this page by clicking the close icon at the top right.
- Copy the IP address at the Virtual machine interface.
Step 2: Connect to the Linux Virtual Machine
- To connect to the Linux Virtual Machine, Open the terminal.
Type in ssh username@IP address at the terminal. The Username used here was created while providing information for the Administrator account in the above steps, while the IP address was copied when the deployment process was complete.
The prompt asks if you want to continue, type yes
- Provide the required login password when prompted again.
- Then the prompt changes to a combination of the username@virtual_Machine_Name. This is evidence of a connection to the Linux Virtual Machine.
Step 3: Install Nginx Server in the Virtual Machine
The next step is installing a Nginx server in the Linux Virtual machine. To do this, log in as the root in the Virtual Machine.
At the terminal type in sudo su to change to root user.
At the next terminal/prompt type apt install nginx to install ngix.
Select yes at the next prompt. This completes the Nginx installation process.
Step 4: Testing the Linux virtual Machine via browser
- To test if everything works perfectly, copy the Linux Virtual Machine IP address from the Azure portal and paste it into a browser. If you can see the image below in your browser, it means everything is working well.
Conclusion
This concludes my post on creating a Linux Virtual machine in Azure using Password Authentication.
It is advised that the resource created in the Azure portal be deleted when not used.
In the next post, I will write about creating a Linux Virtual machine in Azure using SSH Authentication.
Top comments (0)