Subscribe Now

* You will receive the latest news and updates on the Canadian IT marketplace.

Trending News

Blog Post

How To: Using PowerShell to build virtual machines in Azure
HOW TO

How To: Using PowerShell to build virtual machines in Azure 

There is an implementation shortcut for this process that IT managers can easily benefit from. It involves the ability to use Azure PowerShell cmdlets to build virtual machines that developers rely on. These cmdlets help IT to properly define the configuration of a virtual machine through advance configuration options that include:

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

Here is how the process works.

  1. Register for the free 30-day trial of Azure.
     
    NOTE: Upon activation of the trial, you will be asked to provide credit card information.  This is used only to validate your identity. You will not be charged, unless you decide to convert your free trial account into a paid subscription later on.
     
  2. Download the Azure PowerShell modules and install them via the Microsoft Web Platform installer.

The fast track

There are two ways to build a virtual machine using the cmdlets in Azure PowerShell. For this example, we will examine the New-AzureQuickVM cmdlet. The second method will be described in a future article.

This cmdlet allows for the provisioning of a single simple configuration-based virtual machine. It will not, however, allow you to specify any additional endpoints or create data disks during the building process. In this tutorial, the cmdlet will set the instance size to small by default and add it to the CANITPRO-vms cloud service based in the East U.S. region.

Launch the newly-installed Azure PowerShell console and enter the following information:

$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

Make sure to modify the $serviceName, $location, etc., to align with your requirements.

In a future article, I will discuss the second method of VM creation using Azure PowerShell, which provides additional configuration capabilities. Stay tuned.

Related posts