The recent announcement about the general availability of Windows Azure IaaS comes with the following key enhancements:

  1. Remote PowerShell is enabled by default when deploying Virtual Machine using PowerShell.
  2. Availability of trial images such as SharePoint in the image gallery.

These enhancements make it easy to deploy a SharePoint Farm in an automated manner using PowerShell scripts.

The goal of this blog post is to walk you through such a script.

All of the sample code discussed in this article is available here. (Please note that this is a sample script, provided as-is without any warranties.)

We are going to assume the following SharePoint topology (although you can modify the scripts based on your needs):

  • Windows gallery image hosted on a small VM instance, serving as the Active directory machine.
  • SQL Server 2012 Standard gallery image hosted on a large VM instance, serving as the database server.
  • Two SharePoint 2013 trial gallery images hosted on a  medium VM instance,  serving as SharePoint Web Ends.

We decided to leverage PowerShell workflow, and as a result you need to have PowerShell version 3 installed to run the script.

We choose to use workflow for the following reasons:

  • Ability to resume a workflow from a previous state using checkpoints. (More information here.)
  • Ability to extend the script to run tasks in parallel.

Steps to execute the script are listed below:

  1. Download and install the latest Windows Azure PowerShell Cmdlets.
  2. Enable delegation of credentials on the local machine where this script will run.
    1. Enable-WSManCredSSP -Role Client -DelegateComputer *.cloudapp.net -Force
    2. Open gpedit.msc and browse to Computer Configuration > Administrative Templates > System > Credentials Delegation.Double-click “Allow delegating fresh credentials with NTLM-only Server Authentication.”Enable the setting and add the build server to the server list as *.cloudapp.netDouble-click “Allow delegating fresh credentials.”

      Enable the setting and add the build server to the server list as *.cloudapp.net

  3. Create a Virtual Network with a Subnet by following these steps.
  4. Download the script from github repo
  5. Change the Subscription, Network and Affinity group values in the script ( you will find these settings towards the end of file SPWF.ps1)
  6. Execute the script SPWF.ps1.

Note: In order to avoid Azure CloudService DNS name conflicts, we have a very simple scheme to append the name with a randomly generated five-letter string. You can replace this logic with something that best meets your needs.

At a high level, the script is designed to execute the following steps:

  1. Create a Windows 2012 VM, using loopback address as DNS address, and wait for its boot using –WaitForBoot parameter in the scripts.
  2. Retrieve the certificate from the VM and install it on client computer for executing the commands using WinRM overhttps.
  3. Once the VM is up, it installs the AD and promotes it as the DNS.
  4. Adds required service accounts and domain users.
  5. Once the above steps are complete, it provisions the following machines in parallel, with “domain join” arguments. This way the machines are joined to the AD upon boot up.
    1. SQL Server 2010 standard (1 VM)
    2. SharePoint trial (2 VMs)
    3. Change the service account of SQL Server to use domain service accounts.
    4. Set the max degree of parallelism to 1 for the SQL server.
    5. On SharePoint server 1, create a new farm using configuration scripts.
    6. On SharePoint server 2, run a script to join the already provisioned farm.
    7. Installs remaining services and central administration on SharePoint server 1.

Please tell us about your experience and we hope this helps!

Click here to read more thoughts on the recent IaaS GA announcement. Contemplating a move to the cloud? We can help