The Clear Cloud - Home
On Demand Virtualization: Automated Provisioning of Multiple VMs on Azure Cloud
JUL 18, 2016 04:36 AM
A+ A A-


This article attempts to make the readers aware of a relatively new frontier in SDLC process automation, which is automated provisioning of Virtual Machines. Provisioning an environment for your application deployment involves two major tasks; one is, to provision machines and the second is, to configure them with required OS, services, tools and software frameworks, popularly called as prerequisites. Infra configuration management tools like Ansible, Chef or Puppet have made automation of #2 possible since a while back, but provisioning the machines was still dependent on “traditional” IT rather than being a service enabled by DevOps. As organizations moved towards adopting cloud and virtualized environment the feasibility of automated provisioning opened up. Concept of immutable servers and Infra as code made it possible to decouple manual interventions from your DevOps enabled IT services. However modern digital organizations didn’t yet find the desirable agility given that the overall time though significantly reduced and it couldn’t be integrated into their CI/ CD pipeline, thereby restricting an automation which could be truly E2E.

So the next level of automation which Development teams wanted to achieve is provisioning of different environments on platform of their choice like Azure or AWS cloud or a VMWare and that too on demand & at one click. This automation not only gives ease of on-demand environment provisioning to Developers and testers but also significantly reduced their idle/ waiting time.


In a digital world, both business and development team continuously try to increase agility at each stage of application lifecycle management. Continuous integration and deployment are standard practices in agile development, but to further automate the processes and have better control at each stage of SDLC, development teams have moved to next level of DevOps practices and have started to not just adopt tools like Ansible, Chef or Puppet etc. for infra configuration management but also look for solutions that offer automated provisioning of environment where their application would be deployed. This gives flexibility to developers and testers to create an environment, run their tests and tear it down once their task is completed- in real time, on-demand with one click. This enables a true end to end (E2E) automation of build, provision, deploy, test and dispose. Creating a cluster of pre-configured VMs on demand is an essential pre-requisite to enable this E2E automation. Today organizations have developed solutions to enable one-click virtualizations on different virtualization platforms like AWS, Azure, VMWare etc.

In this article we will focus on one such solution which we created for on-demand one-click Azure VMs provisioning.

Azure resource manager lets you deploy a wide range of computing solutions in an agile way. On a day to day basis we need to provision, use and then destroy a number of virtual machines on Azure that can be used for testing and development purposes. But it is manual process where you need to login to Azure management portal and use different menu options to create VMs one by one.

Problem Statement

Manual process of creating VMs from Azure Management Portal is time consuming, prone to human errors and a security concern.

To provision a new VM from Windows Azure Management Portal we need to share its credentials, using which team member would login to portal. This is not only a time consuming process with probability of human errors but it also adds security concern of sharing the login details with member of QA/Dev team; whoever need this service.

Automated Provisioning

This problem can be resolved using one of the following approach:

Azure PowerShell

Azure PowerShell provides us a package of modules that in turn consists of cmdlets to manage Azure with Windows PowerShell. These cmdlets can be used to create, test, deploy, and manage solutions and services delivered through the Azure platform. In most of the scenario, the cmdlets can be helpful to do the same tasks as the Azure Management Portal, like creating and configuring cloud services, virtual machines, virtual networks, and web apps

Azure CLI

Azure CLI, written in node.js, provides a cross-platform command line interface (Unix, windows etc.) for developers and IT administrators to develop, deploy and manage Microsoft Azure applications. They're do not fit with in for scripting multiple actions, but are of great help for developers that prefer the command line to execute tasks (instead of going to the Azure management portal).

We will preferably focus here on “Azure PowerShell programming”, because of its abilities of automating concurrent tasks, to fully automate multiple Azure VMs spawn process.

How it adds value

  • This technique helps to reduce execution time when we have to deploy, start, stop or remove multiple azure virtual machines in between the phases of the various development and testing activities.

  • In a general scenario Dev/QA teams has a dependency on CloudOps/ IT team to provide the servers for their testing purposes. With this approach they do not need to create service requests to Devops/CloudOps for vm provision to validate their test scenarios.

  • Minimize costs due to manual errors and inefficiency.

  • To replicate processes consistently and with better quality than a human.


This document will walk through a deployment that uses Azure PowerShell cmdlets to create multiple VM machines in Azure Cloud. This tutorial shows you how easy it is to create a stack of VMs in just a few minutes using the Azure PowerShell cmdlets.

Before You Begin

  • Get an Azure subscription ID.

  • Install Azure PowerShell and sign in to your Azure account.


Here are some of the basic cmdlets which can be used to create a VM.

Get-AzureVMImage cmdlet provides detail for all images in the repository, or about a specific image if its image name is provided.

New-AzureVMConfig creates a new virtual machine configuration object that can be used to perform a new deployment. It can also be used to add a new virtual machine to an existing deployment.

Add-AzureProvisioningConfig adds configuration information to a virtual machine configuration which is later used to create a fresh VM.

New-AzureRmVM creates a new VM in Azure. This command takes a virtual machine object as input.

The PowerShell commands all work together and data is passed between them. In this case, a new Azure VM configuration is created using New-AzureVMConfig while the VM Name is pull from the list using Get-AzureVMImage, then a provisioning config object is passed into New-AzureVM.

To start with, we follow the below steps, in order to create a cluster of VM’s:

  • First create a resource group on your Azure infrastructure.

  • Then provision a storage account. A storage account is needed to store the virtual hard disk that is used by the virtual machine that you create.

  • Create a virtual network or use an existing one where you want to add new VMs.

  • To enable communication with the virtual machine in the virtual network, you need a public IP address and a network interface. Create a public IP address and network interface.

  • Define the image to use to provision the virtual machine.

  • Provide the no of VMs to be provisioned.

  • Create VM Role (VmName, Instancesize, Username, Password) for the new Vm’s.

  • Now that you have all the pieces in place, you are all set to build Multiple VM’s.

  • You should see the resource group and all its resources in the Azure portal and a success status in the PowerShell window.

Process Flow

Using Azure PowerShell to communicate with Azure cloud







Azure PowerShell is great for automating several concurrent tasks (i.e. scripting out an entire environment), or carrying out single tasks. Environment), or carrying out single tasks.

The PowerShell cmdlets work only in PowerShell (on Windows machines).




Nitin Shah is a Solution Architect with primary expertise in Digital Transformation Technologies and Consulting services. He currently leads the DevOps CoE , part of the Technology Office in Engineering and R&D Services group of HCL Technologies

Rashi Sharma is a technical lead in DevOps COE , part of the Technology Office in Engineering and R&D Services group of HCL Technologies. She has contributed in development of various DevOps solutions that HCL has created. She has worked on various Tools and technologies like AWS cloud, Oracle cloud , Chef, Jenkins, Teamcity, Linux/Windows platform etc.

[%= name %]
[%= createDate %]
[%= comment %]
Share this:

Computing Now Blogs
Business Intelligence
by Keith Peterson
Cloud Computing
A Cloud Blog: by Irena Bojanova
The Clear Cloud: by STC Cloud Computing
Computing Careers: by Lori Cameron
Display Technologies
Enterprise Solutions
Enterprise Thinking: by Josh Greenbaum
Healthcare Technologies
The Doctor Is In: Dr. Keith W. Vrbicky
Heterogeneous Systems
Hot Topics
NealNotes: by Neal Leavitt
Industry Trends
The Robotics Report: by Jeff Debrosse
Internet Of Things
Sensing IoT: by Irena Bojanova