Closing the loop: New topic for creating Windows-based Azure virtual machines with PowerShell is based on your feedback


Greetings SAB Members,

At the October 2014 SAB Webinar, I talked about using PowerShell command blocks to automate the configuration of Azure virtual machines. I had a brief poll slide to gauge your comfort level with PowerShell.

The consensus was that many of you were comfortable enough with PowerShell to create or use blocks of PowerShell commands but were not doing self-contained scripts or PowerShell programming.

Based on this feedback, I recently published the Use Azure PowerShell to create and preconfigure Windows-based Virtual Machines topic, which steps you through building an Azure PowerShell command set that creates and pre-configures a Windows-based Azure virtual machine. Pre-configuration elements include:

  • Joining an existing Active Directory domain
  • Adding one or more data disks
  • Specifying a static IP address (known as a static DIP)
  • Specifying a subnet and virtual network
  • Specifying membership in a load-balanced set

I have taken the "fill-in-the-blanks approach," in which you specify your custom values using PowerShell  variables so that you do not have to know or determine the correct values for PowerShell cmdlet parameters. It is not the tightest PowerShell code, but rather is designed for customization ease and configuration success.

Here is an example Azure PowerShell command set from the topic to build an Azure virtual machine that will later be configured as a replica domain controller:

$family="Windows Server 2012 R2 Datacenter"
$vmname="AZDC1"
$vmsize="Medium"
$image = Get-AzureVMImage | where { $_.ImageFamily -eq $family } | sort PublishedDate -Descending | select -ExpandProperty ImageName -First 1
$vm1=New-AzureVMConfig -Name $vmname -InstanceSize $vmsize -ImageName $image

$localadminusername="DCLocalAdmin"
$localadminpassword="DCeq7294*"
$vm1 | Add-AzureProvisioningConfig -Windows -AdminUsername $localadminusername -Password $localadminpassword

$vm1 | Set-AzureSubnet -SubnetNames "BackEnd"

$vm1 | Set-AzureStaticVNetIP -IPAddress 192.168.244.4

$disksize=20
$disklabel="DCData"
$lun=0
$hcaching="None"
$vm1 | Add-AzureDataDisk -CreateNew -DiskSizeInGB $disksize -DiskLabel $disklabel -LUN $lun -HostCaching $hcaching

$svcname="Azure-TailspinToys"
$vnetname="AZDatacenter"
New-AzureVM –ServiceName $svcname -VMs $vm1 -VNetName $vnetname

 

Just like the hybrid cloud test environment topics, it was your feedback at the October 2014 SAB Webinar that helped me understand your needs for PowerShell automation documentation. In short, your input made this content possible.

I have also published a companion article for Linux-based Azure virtual machines. See Use Azure PowerShell to create and preconfigure Linux-based Virtual Machines for the details. 

Thank you all so much!

Enjoy.

 

Joe Davies
Senior Content Publisher

 

If you have questions, or if you’d like to join the SAB, email us at SAB@microsoft.com.

 

Comments (0)

Skip to main content