DevOps Basics: Quickly Creating Azure Virtual Machines via PowerShell

PowerShell, as highlighted numerous times in CANITPRO.NET, can quickly complete tasks normally conducted over numerous steps found in a GUI interface. In light of this, harnessing PowerShell in Azure for purposes of satisfying requirements put forth by DevOps practices, can substantially speed up resource setup time through automation. One easy implementation any IT administrator could take advantage is the ability to use Azure PowerShell cmdlets to quickly create virtual machines needed by developers.

Azure PowerShell cmdlets allow IT professionals to define the configuration of a virtual machine including advance configuration options such as:

  • Data disks
  • Network Endpoints
  • Active Directory domain join information 

Getting Started

  1. Sign up for the 30 day Azure Trial
    NOTE: When activating your FREE Trial for Microsoft Azure, you will be prompted for credit card information.  This information is used only to validate your identity and your credit card will not be charged, unless you explicitly convert your FREE Trial account to a paid subscription at a later point in time.
  2. Download and install the Azure PowerShell modules via the Microsoft Web Platform installer


Utilizing Azure PowerShell to create a Virtual Machine quickly

There are currently two methods of creating a virtual machine via Azure PowerShell cmdlets. For this example, the New-AzureQuickVM cmdlet will be used and the second method detailed on a later post. This cmdlet enables the provisioning of a single simple configuration based virtual machine and will not allow one to specify additional endpoints or create data disks during the virtual machine's creation.

The following cmdlet will set the instance size to small, add it to the CANITPRO-vms cloud service in the East US region. Open the newly installed Azure PowerShell console and enter the following:

$adminUser     = "[admin user name]"
$password       = "[admin password]"
$serviceName  = "CANITPRO-vms"
$location         = "East US"
$size               = "Small"
$vmName        = "vm1"
$imageFamily = "Windows Server 2012 R2 Datacenter"
$imageName = Get-AzureVMImage |
                            where { $_.ImageFamily -eq $imageFamily } |
                                              sort PublishedDate -Descending |
                            select -ExpandProperty ImageName -First 1
New-AzureQuickVM -Windows `
                                 -ServiceName $serviceName `
                                 -Name $vmName `
                                 -ImageName $imageName `
                                 -AdminUsername $adminUser `
                                 -Password $password `
                                 -Location $location `
                                 -InstanceSize $size

Be sure the change the $serviceName, $location, etc, to the requirements needed.

The second method of VM creation via Azure PowerShell providing further configuration abilities will be detailed in a future CANITPRO.NET post.

Comments (0)

Skip to main content