Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Automating Windows Azure IaaS Deployment with Powershell

DZone's Guide to

Automating Windows Azure IaaS Deployment with Powershell

· Cloud Zone
Free Resource

Deploy and scale data-rich applications in minutes and with ease. Mesosphere DC/OS includes everything you need to elastically run containerized apps and data services in production.

With Windows Azure PowerShell Cmdlets, the process to customize and automate an infrastructure deployment to Windows Azure Infrastructure Services (IaaS) becomes a relatively simple and manageable task. This article examines a sample script which automatically deploys seven specified VMs into three target subnets based on a network configuration file with two availability sets and a load-balancer. The entire deployment took a little more than half an hour.

Assumptions

The developer PowerShell script assumes Windows Azure PowerShell Cmdlets environment has been configured with an intended Windows Azure subscription. A network configuration file is in a specified location.

Network Configuration (netcfg) File

This file can be created from scratch or exported from Windows Azure NETOWRK workspace by first creating a virtual network. Notice in the netcfg file an affinity group and a DNS server are specified.

image

Overall Program Structure

The four functions represent the key steps in performing a deployment including building a virtual network, deploying VMs, and configuring availability sets and load-balancers, as applicable.

image

Initialization, Windows Azure Virtual Network and Settings

Within the script, session variables and constants are assigned. The network information needs to be identical with what is defined in netcfg file since they are not automatically populated from an external source at this time.

image

Functions

To deploy multiple VMs programmatically, there is much information repeated. And in some parameters are defined with default values from session variables or the initialization section. When calling a routine, a default value can be overridden by an assigned/passed value.

image

Since other than the first VM, deploying additional VMs into an existing service does not need to specify the virtual network name. I however employ the same routing with VNetName specified for deploying the first and subsequent VMs into a service, it produces a warning for each VM after the first VM deployed into a service as shown in the user experience later.

image

Simply passing in an array to the routines and an availability set or a load-balancer will automatically built. These two functions streamline the processes.

image

image

Main Program

Rather than creating a cloud service while deploying a VM, I decided to create individual cloud services first. This makes troubleshooting easier since it is very clear when services are created.

image

Deploy Backend Infrastructure Servers

With a target service in place, I simply loop through and deploy VMs based  on the names specified in an array. So to deploy or place VMs into an availability set or a load-balancer becomes simply by adding machine names into a target array.

image

Deploy Mid-Tier Workloads

image

Deploy Frontend Servers

Here, three frontend servers are load-balanced and configured into an availability set.

image

User Experience

I kicked off at 3:03 PM and it finished at 3:36 PM. The four warnings were due to deploying additional VMs (specifically dc2, sp2013, fe2, and fe3) into their target services while in the function, DeployVMsToAService, I have VNetName specified.

image

Verified with Windows Azure Portal

Seven VMs were deployed with specified names.

image

dc1 and dc2 were placed in the availability set, dcAvSet.

image

fe1, fe2, and fe3 are placed in the availability set, feAvSet.

image

The three were load-balanced at feEndpoint as specified in the script.

image

All VMs were deployed into target subnet as shown in the virtual network, foonet.

image

Session Log and RDP files

The script also produces a log file capturing the states while completing tasks. As a VM is deployed, the associated RDP file is also downloaded into a specified working directory as shown below.

image 

Closing Thoughts

To make the code production ready, more error handling needs to be put in place. A key missing part of the script is the ability to automatically populated the network configuration from or to an external source. Still, the script provides a predictable, consistent, and efficient way to deploy infrastructure with Windows Azure Infrastructure. What must come after is to customize the runtime environment for an intended application, once VMs are in place and followed by installing the application. IaaS outs VMs in place as the foundation for PaaS which provides the runtime for a target application. It is always about the application, never should we forget.

- See more at: http://blogs.technet.com/b/yungchou/archive/2013/05/20/automating-windows-azure-infrastructure-services-iaas-deployment-with-powershell.aspx#sthash.7JxjChsU.dpuf

Discover new technologies simplifying running containers and data services in production with this free eBook by O'Reilly. Courtesy of Mesosphere.

Topics:

Published at DZone with permission of Yung Chou, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}