Launching Linux based VMs in Azure

Introduction

Infrastructure-as-a-Service (IaaS) provides you with the on-demand computing infrastructure that can be provisioned and managed easily over the Internet. The key advantage of using IaaS is that it will eliminate CAPEX and OPEX costs for the organization. Azure’s IaaS services can be leveraged for scenarios such as:

  • Hosting enterprise workloads
  • Creating Test and Development environments
  • For storage, backup and recovery options
  • To host websites
  • For big data analysis and HPC
Azure Virtual Machines, Virtual Networks, Azure Storage, HDInsight, etc. are the IaaS offerings from Azure.
azure virtual machine

Azure Virtual Machine (VM) allows IT professionals to provision a Windows or Linux based server in minutes. With Azure Virtual Machines, you get the flexibility of virtualization for a variety of computing solutions and support for Linux, Windows, SAP, Oracle, SQL Server, IBM, and more. Virtual Machines can be deployed from two models: ASM and ARM. However, deploying VMs in both the models have a few key differences.

When a VM is deployed in Azure Service Manager (ASM), there is a virtual container called Cloud Service around it, whereas the VM deployed in Azure Resource Manager (ARM) belongs to a particular Resource Group. Virtual machines of a similar kind can be deployed in a single cloud service. By default, in ASM, virtual machines deployed in the cloud service don’t have public IP address associated with them.

This isn’t the case in ARM since all the virtual machines in ARM have NIC attached to it which can have public IP address associated. In ASM, there is an option to deploy a VM quickly, without creating VNet and other dependencies. This is not possible with ARM deployments.

To know more in detail about ASM and ARM deployment models, have a look at guide “Understanding key differences between Azure ASM and Azure ARM“.

Requirements
Azure Services

An ACTIVE Azure Subscription is required to provision a VM. In addition, a Resource Group, which can be created while provisioning a VM, is required. Other resources include a storage account to store VM disks, a virtual network with a subnet, a public IP address, and a security group.

SDKs and Other Tools

For a Windows based VM, Remote Desktop clients like Remmina (Ubuntu) or Remote Desktop Connection (Windows) are required. Here we will launch a Linux instance so any Linux CLI can be used to connect to the VM via SSH. SSH client like PuTTY can be used to SSH from Windows machines.

Getting Started

To get started with Virtual Machines from the Azure portal, navigate to portal.azure.com and enter your account credentials to log in. Click on New and then Compute and select Ubuntu Server 16.04 LTS.

user_60255_5944ffb3071a6.PNG

On the next page, select Resource Manager from the Select a deployment model menu and click Create.

user_60255_594500191c09e.PNG

Configuring VM Basics

Enter an appropriate name for the VM. For the disk type, select HDD. Enter the username and for Authentication Type, we can proceed with Password authentication for simplicity, but the SSH public key option will be explained below. Select an appropriate Subscription. Under Resource Group, select Create New and enter a Resource Group Name. Select the Location to provision a VM.

user_60255_59450094342eb.PNGuser_60255_594500b7da293.PNG

Linux VMs support two types of authentication:

  1. Password authentication
  2. SSH key authentication

For SSH public key authentication, we have to provide a public key file which can be generated using the ssh-keygen command on Linux, or PuTTYGen on Windows. You can download PuTTYGen here.

To generate a public key and private key using PuTTYGen, follow these steps:

  1. Open PuTTYGen and click Generate. Make some random movements in the blank area using a mouse to create entropy. user_60255_594503101eac8.PNG
  2. Save both Public key and Private key files: user_60255_594503388f666.PNG
  3. Copy the generated public key and paste it in VM Basics blade by selecting the SSH public key option user_60255_5945044f7330f.PNG
The PrivateKey.ppk file will be used to SSH into VM later.
Choosing VM Size
Azure offers two pricing tiers for VMs:

  • Basic Tier
  • Standard Tier

Basic Tier VMs don’t support SSD storage or Load Balancing between VMs. There are also limited sizes available for Basic tier VMs. Standard tier supports Premium Storage (SSD) and Load Balancing.

For this guide, we will go with Standard D1_V2 size.

user_60255_594505b665bb8.PNG

Configure Additional Resources

Various other resources like storage account, virtual network, IP Address, security group, etc. that support VM provisioning can be configured from this blade. Click on Storage account to choose an existing storage account (if any). Otherwise, leave the default settings as shown below.

user_60255_5945063277b52.PNG_800.jpg

Click on Virtual network. Choose an existing virtual network (if you have one). Otherwise, leave the default settings and save.

user_60255_59450747138f9.PNG_800.jpg

Leave the public IP address settings as it is. A Static IP can be allocated here. We will keep the IP assignment as Dynamic.

user_60255_59450772cade6.PNG

In Network Security Group, we will add one inbound rule for HTTP. Click on Add an inbound rule.

user_60255_594507a1618c1.PNG

For the name, enter Allow-HTTP, set the Priority to 100 and from the Service menu, select HTTP. The Action should be set to Allow. Save these settings.

user_60255_5945087099bdc.PNG

Leave other settings as default and click OK.

user_60255_594508ad0c5b6.PNG

Validate VM Settings and Launch

On the Summary page, verify all the settings and click OK to start provisioning the VM.

user_60255_594508e302eda.PNG

Login to Ubuntu VM

Once the VM is up and running, the next task is to log in to the VM. We will use PuTTY from Windows to SSH into newly launched Ubuntu VM. PuTTY can be downloaded from here. Note down the Public IP of the Ubuntu VM.

user_60255_59450950e0f51.PNG

Launch PuTTY. Enter the public IP of the VM in Host Name (or IP address) in PuTTY and click Open. For key based authentication, Private key (.ppk) can be selected from SSH > Auth option and select the .ppk file.

user_60255_594509edb160d.PNG

Accept the server’s host key configuration when asked in PuTTY. Enter your username and password in the PuTTY console to login.

user_60255_59450a3ba4fbd.PNG

Install Apache Web server

To install apache2 web server in Ubuntu machine enter the following command:

sudo apt-get install apache2

Once the installation is successful, navigate to the server’s IP address from the browser. You’ll see the following page:

user_60255_59450a92071a6.PNG_800.jpg

Where to go next?

Deep dive into Azure with Linux Academy courses listed below:

Looking for team training?