- Remote PowerShell is enabled by default when deploying Virtual Machine using PowerShell.
- 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:
- Download and install the latest Windows Azure PowerShell Cmdlets.
- Enable delegation of credentials on the local machine where this script will run.
- Enable-WSManCredSSP -Role Client -DelegateComputer *.cloudapp.net -Force
- 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
- Create a Virtual Network with a Subnet by following these steps.
- Download the script from github repo
- Change the Subscription, Network and Affinity group values in the script ( you will find these settings towards the end of file SPWF.ps1)
- 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:
- Create a Windows 2012 VM, using loopback address as DNS address, and wait for its boot using –WaitForBoot parameter in the scripts.
- Retrieve the certificate from the VM and install it on client computer for executing the commands using WinRM overhttps.
- Once the VM is up, it installs the AD and promotes it as the DNS.
- Adds required service accounts and domain users.
- 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.
- SQL Server 2010 standard (1 VM)
- SharePoint trial (2 VMs)
- Change the service account of SQL Server to use domain service accounts.
- Set the max degree of parallelism to 1 for the SQL server.
- On SharePoint server 1, create a new farm using configuration scripts.
- On SharePoint server 2, run a script to join the already provisioned farm.
- 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.