- Microsoft free account and Azure Credits.
- Basic knowledge of using Azure Services and understanding of PaaS and IaaS models.
In this article, we will cover the following topics:
- Create and configure the Linux VM.
- Remotely access Linux VM using Putty.
- Install workloads on Linux VM like nginx Web Server.
- Run nginx Web Server as container on Docker hub.
Step 1 - Create and configure Linux VM
The account creation will require you to provide your credit/debit card details for validation. The first month of the Azure Subscription is free and you will not be automatically charged unless you upgrade your account manually.
Once the account is created successfully, we can log into the Azure Portal using this
link.
The home screen will display all recently used Azure resources.
Under Virtual machines, click add a new VM.
A Resource Group is a logical grouping of resources.
Any Azure service is a resource.
The user can create a new resource group and select Ubuntu Server Image for our VM configuration
Configure an admin user that would be used to communicate remotely with the VM.
The SSH communication happens through port 22.
We can select the VM CPU Size and RAM Size and our cost will vary as per the selected size.
Configure Disk type and Size
This is the OS Disk. Additionally, we can add a storage disk.
Configure the networking tab with the default settings and we are good to go.
It will create a new VPN and a subnet mask.
Review the final changes and click on create. Our VM machine is deployed and ready for use in less than 5 minutes.
Step 2 - Remotely access VM from our local machine
To remotely connect the Linux VM, we would need to download Putty.
Putty can be download from this link https://www.putty.org/.
Install putty on your local machine.
Once the installation is complete, launch putty and enter the public IP address of your VM
SSH communication happens through Port 22. Under the Networking tab, check to ensure port 22 is enabled.
Enter the admin credentials configured in step 1 and we are good to go.
We are now connected to our Linux VM.
Step 3 - Install workloads on Linux VM
Once we log on to our Linux VM, our next step is to update the package index, as shown below.
Once the package index has been updated, our next step is to install the nginx Web Server, as below
Once the nginx server installation is complete, then enable port 80 in the networking tab.
We need to add the Inbound port rule under the networking tab and enable port 80
We have now added a rule to allow traffic on port 80 for our virtual machine.
Now navigate to your public Ip address and you will see the nginx server up and running.
Thus, we have successfully installed nginx server to our Linux virtual machine.
Step 4 - Installing Docker on Linux VM
Connect to our Linux VM using Putty and run the following commands.
Update the apt package index and install packages to allow apt to use a repository over https
$ sudo apt-get update
$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
Add Docker’s official GPG key,
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
Go ahead and add a valid repository
$ sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu \$(lsb_release -cs)\ stable"
Update the package index
$ sudo apt-get update
Install docker engine
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Once the docker engine is installed execute the below pull command to pull nginx engine from docker hub
sudo docker pull nginx 1.17.0
To run the container out of an image, execute the below command
sudo docker run --name sampleapp -p 80:80 -d nginx:1.17.0
Navigate to the public IP address and we can now see the nginx server up and running as a container on the docker engine.
Summary
In this article, we have learned how to create and configure a Linux VM, install docker engine, and run nginx server as a container on Linux VM.
In our next article, we will deploy our .NET Core application to the docker container installed on our Linux machine.
Thanks a lot for reading. I hope you liked this article. Please share your valuable suggestions and feedback. Write in the comment box in case you have any questions. Have a good day!