Scripting provisioning & tear down of SharePoint farms in Windows Azure

Windows azure provides a feature called Virtual Machines, basically it allows us to provision the infrastructure that is required to run your on premise applications in Windows Azure. For a list of server products that are supported to run on Azure Virtual Machines see SharePoint is one of the server products that is already supported. I’m sure you are probably thinking why would I want to do this, what benefits do I have, What are some of the key usage scenarios, etc. Windows Azure team has already published a really nice article that might answer all your questions

In this post I will walk through the scripted solution I built for automating provisioning and teardown of SharePoint farms in Windows Azure. Before you can use Windows Azure PowerShell CmdLets, there is some prep work you have to do.  You should pretty much follow this article to configure your environment.

Provisioning Virtual Machines

High level steps

  • Create the Environment configuration file – Defines parameters for specific environment to provision
 <Environment Name="VMLAB">
    <!-- Azure Subscription Name -->
    <SubscriptionName>Windows Azure MSDN - Visual Studio Ultimate</SubscriptionName>
    <!-- Affinity Group -->
        <Location>West US</Location>
        <Description>Virtual Machine Lab Affinity Group</Description>

    <!--Storage Account -->
        <!-- name must only contain lowercase characters and number -->
    <!-- Additional Disks that will be added to all SharePoint Servers to be used for Storing Data and Logs -->

    <!-- Virtual Network -->

    <!-- Active Directory DEPLOYMENT -->
        <Description>VMLAB AD And DNS Service</Description>
        <!-- DNS Settings -->

            <!-- Domain Controller -->
            <Machine Role="DC">
        <Description>VMLAB SharePoint 2010 Application Service</Description>

            <!-- Web Servers -->

            <!-- Application Servers -->

            <!-- Database Servers -->

  • Run BuildADEnvironment.ps1 to create a affinity group, storage account, virtual network, cloud service and necessary VMs for AD environment defined in the environment configuration file.

  • Create a new Active Directory Forest in Windows Azure – Good resource for reference

    • RDP into the virtual machine
    • Initialize and mount the two data disks added, using the disk management tool. One is supposed to be used for LOGS and other for DATA
    • Add Role “Active Directory Domain Services”
    • Run DC Promo and create a new Active Directory Forest/Domain
    • Create an OU for virtual machines that will be provisioned and domain joined.
  • Before we can provision the virtual machines used for SharePoint farm we need to copy a base VHD I created ahead of time from a backup storage account to the new storage account created for this environment. VHDs for custom base images need to be in the same storage account, otherwise the VM provisioning will fail. For more details see this post on creating/reusing custom images in window azure.

  • Run BuildEnvironment.ps1 to create all the virtual machines for SharePoint farm. This script will prompt to enter the environment configuration file and the password that was initially used for domain Administrator account during step 2

From the screen shot below you can see all Virtual Machines are successfully provisioned and running



Screen shot below of my RDP window to “VMLAB-DC” shows the virtual machines are also domain joined to “” which is the domain that I created for the purposes of this post.



Finally screen shot of the RDP window to “SP-APP1” VM shows software and scripts required to provision a SharePoint farm. You could simply kick of the script to complete the SharePoint install and configuration.



Tear Down

In the tear down script we simply reverse everything we did, when the script is kicked off, it takes the environment configuration file as parameter and start tearing down the environment that was build out, nothing more to it. Some times I do have to run few times to fully clear everything out.

To wrap it up this really allows me to rapidly build and tear down SharePoint environments for vendors, develop teams etc. I’m really excited about Azure IaaS and the opportunities it brings and can’t wait for the feature to be out of preview :)

Final thing I will make all the scripts used in this post available so you can download and use it for your needs as well, if it helped you please feel free to drop a note and I appreciate it. I will just update this post after I’m able to package and publish the scripts.

Link to download scripts from TechNet script center