Microsoft Azure App Service is an HTTP-based service for REST APIs, hosting web applications, and mobile back ends. Users can develop these apps in their favorite language like Java, Ruby, .NET, .NET Core, Node.js, Python, or PHP. In addition, azure applications can scale and run on both Linux and Windows-based environments with ease.
Users can create Azure Virtual Machines (VMs) through the Azure portal. The Azure portal is a web-based user interface to create Azure resources. This tutorial presents the steps to use the Azure portal to deploy a Linux virtual machine (VM) running Ubuntu 18.04 LTS. To see the created Virtual Machine in action, the user also needs to SSH to the Virtual Machine and install the NGINX web server. If the user does not have an Azure subscription, create a free account before starting this tutorial.
Create Virtual Machine
To create a Virtual Machine in Microsoft Azure, follow the below steps:
1. First, sign in to the Microsoft Azure portal.
2. Search virtual machines in the search bar.
3. Under Services, choose Virtual machines.
4. On the Virtual machines page, select Add.
5. After that, the Create a virtual machine page opens.
6. Make sure to select the correct subscription in the Basics tab under the Project details section.
7. Then, create a new resource group and enter the group name, such as myResourceGroup.
8. Under the Instance details section fill in the following parameters:
· Virtual machine name: Enter a name for the Virtual Machine. For example, myVM.
· Region: Choose a region where the user wants to create the Virtual Machine. For example, East US.
· Image: Select an ISO image. For example, Ubuntu 18.04 LTS.
· Leave all other parameters as defaults.
9. Under the Administrator account section, select the SSH public key option as the authentication type.
10. In the Username section, mention a name for the administrator user. For example, azureuser.
11. For SSH public key source, leave the default setting of Generate new key pair, and then enter a Key pair name, such as myKey.
12. Under Inbound port rules, Select Allow selected ports in the Public inbound ports section.
13. After that, select SSH (22) and HTTP (80) from the inbound ports drop-down.
14. Leave the remaining settings as defaults and click the Review + create button at the bottom of the page.
15. On the Create a virtual machine page, users can view all the details about the Virtual Machine that they are about to create. After the review, click Create.
16. Select Download private key and create resource when the Generate new key pair window opens. The system will download the key file as <key_name>.pem (myKey.pem). Make sure to remember where the .pem file was downloaded, as we will need the path to it in the next step.
17. After that, select the Go to resource button.
18. On the page for the new Virtual Machine, select the public IP address and copy it to the clipboard.
Connect to the Virtual Machine
To connect to the created Virtual Machine, follow the below steps:
1. If the user has a Linux or Mac machine, open a Bash prompt. If they are on a Windows machine, open a PowerShell prompt.
2. At the command prompt, open an SSH connection to the virtual machine by executing the following command. Replace the IP address with the virtual machine’s IP address and replace the path to the .pem with the path to where the SSH key file is stored.
ssh -i .\Downloads\myKey1.pem azureuser@10.111.12.123
Install Web Server
To see the Virtual Machine in action, install the NGINX web server. From the SSH session, update the package sources and then install the latest NGINX package. For the same, execute the following commands:
sudo apt-get -y update sudo apt-get -y install nginx
After the execution is completed, type exit to leave the SSH session.
View the Created Nginx Web Server
Use a web browser of the user’s choice to view the default NGINX welcome page. Type the public IP address of the Virtual Machine as the web address. The public IP address can be viewed on the Virtual Machine’s overview page or as part of the SSH connection string used earlier.
Clean up Resources
When the Virtual Machine is no longer required for the user, delete the resource group, virtual machine, and all related resources. To do so, choose the resource group for the virtual machine and click the Delete button. After that, confirm the name of the resource group to delete and click the Confirm button.
Conclusion
This tutorial presents the steps to deploy a Linux Virtual Machine running Ubuntu 18.04 LTS in the Microsoft Azure portal. Hope this tutorial was helpful, and do reach out to us if you have any query or suggestions.