Azure Series Part 4: Provisioning and accessing the Linux Virtual Machines

Azure offers different on-demand scalable computing resources and linux virtual machines are one of them.

An Azure VM gives you the flexibility of virtualization without having to buy and maintain the physical hardware that runs it. Though we still to perform certain task like configuring, patching, and installing the software that runs on it.

Before creating any VM we need to think of these design considerations: The names of your application resources, the location where the resources are stored, the size of the VM, the maximum number of VMs that can be created, the operating system that the VM runs, the configuration of the VM after it starts, the related resources that the VM needs.

Creating a Linux VM through Azure Portal

Step 1: Sign in to your Azure portal and search for “Virtual Machines”

Click on “+Add” button as shown in below pic

click on add button

Step 2: Configure the VM – Fill the details

  • Select the subscription
  • Select the resource group
  • Provide the Name of the VM
  • Select the region you want your VM to be created
  • if you want scalability, choose an AZ
  • Select the image you want your VM to use, we will select Red Hat Linux image (RHEL)

Step 3: Select the VM size

In the below picture, we have chosen the one with the lowest cost Rs. 273/month (approx. $8) with 1VCPUs, 500 MB RAM and 2 Data Disks

Step 4: To administer the account, setup a username and generate SSH key pair.

The SSH key pair will generate a public key and private key which we see later how to use them during the login.

customize the key pair name and save it somewhere safe

Step 5: Select the inbound port rules

Select port 22 for SSH, port 80 for HTTP traffic and 443 for HTTPS traffic

Step 6: Select the disk storage

You can select from Standard HDD, Standard SDD, and Premium SSD. By Default it will point to Premium SSD and then select the default Encryption as well.

Step 7: Keep the Networking and Management and Advanced section configuration as default.

Networking section config
Management section config

In advanced section we can add some bootstrap script to add in internal settings to VM or install any softwares like apache/nginx servers.

add sample script to install nginx server

Step 8: Add meaningful tags

Adding tags is really important as it will help you manage your resource and in automation of different operation if needed.

add tags

Step 9: Review the configuration and Create the VM

Download the private Key in your local when prompted.

review the config
Deployment progress

Once the VM deployement is complete as shown in above pic you can login to it.

Step 10: Login to the VM

If you are using Windows OS, download Putty from here

To Login to your VM, copy the IP address of your VM from portal’s Overview section and paste it in putty

add the IP address
go to auth section and add .pem file which we downloaded earlier

go to auth section and add .pem file which we downloaded earlier as shown in above picture.

Click on Open and it will start the session, then login with username you gave during the creation of the VM

Creating a Linux VM through Azure ARM templates

Use the below template.json and parameter file to create the VM by automation

template.json

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "type": "string"
        },
        "storageAccountName": {
            "type": "string"
        },
        "accountType": {
            "type": "string"
        },
        "kind": {
            "type": "string"
        },
        "accessTier": {
            "type": "string"
        },
        "minimumTlsVersion": {
            "type": "string"
        },
        "supportsHttpsTrafficOnly": {
            "type": "bool"
        },
        "allowBlobPublicAccess": {
            "type": "bool"
        },
        "allowSharedKeyAccess": {
            "type": "bool"
        },
        "networkAclsBypass": {
            "type": "string"
        },
        "networkAclsDefaultAction": {
            "type": "string"
        }
    },
    "variables": {},
    "resources": [
        {
            "name": "[parameters('storageAccountName')]",
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2019-06-01",
            "location": "[parameters('location')]",
            "properties": {
                "accessTier": "[parameters('accessTier')]",
                "minimumTlsVersion": "[parameters('minimumTlsVersion')]",
                "supportsHttpsTrafficOnly": "[parameters('supportsHttpsTrafficOnly')]",
                "allowBlobPublicAccess": "[parameters('allowBlobPublicAccess')]",
                "allowSharedKeyAccess": "[parameters('allowSharedKeyAccess')]",
                "networkAcls": {
                    "bypass": "[parameters('networkAclsBypass')]",
                    "defaultAction": "[parameters('networkAclsDefaultAction')]",
                    "ipRules": []
                }
            },
            "dependsOn": [],
            "sku": {
                "name": "[parameters('accountType')]"
            },
            "kind": "[parameters('kind')]",
            "tags": {
                "blog": "thewebspark"
            }
        }
    ],
    "outputs": {}
}

parameters.json file

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "value": "eastus2"
        },
        "storageAccountName": {
            "value": "thewebsparksacc"
        },
        "accountType": {
            "value": "Standard_LRS"
        },
        "kind": {
            "value": "BlobStorage"
        },
        "accessTier": {
            "value": "Hot"
        },
        "minimumTlsVersion": {
            "value": "TLS1_2"
        },
        "supportsHttpsTrafficOnly": {
            "value": true
        },
        "allowBlobPublicAccess": {
            "value": true
        },
        "allowSharedKeyAccess": {
            "value": true
        },
        "networkAclsBypass": {
            "value": "AzureServices"
        },
        "networkAclsDefaultAction": {
            "value": "Allow"
        }
    }
}

Azure CLI command to deploy the ARM templates

az deployment group create –resource-group thewebspark-eatsus2-dev –name thewebsparkeastus2dev
–template template.json –parameters parameters.json


So that’s it from the part 4 of this Azure Series.

Hope you liked it!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s