Building a SharePoint 2010 Farm on Windows Azure with PowerShell
With the new Azure Virtual Machines it is now possible to run SharePoint 2010 and 2013 workloads. In my TechEd talks you can learn about the various options to run SharePoint on Azure.
https://channel9.msdn.com/Events/TechEd/NorthAmerica/2012/AZR327
and
https://channel9.msdn.com/Events/TechEd/Europe/2012/OSP334
I won’t rehash those talks again here. What I do want to share is some of the PowerShell code I used to build the farms. First a caveat that these are just rough scripts that I used to build the demo and have lots of opportunities for improvements. The script are good at demonstrating the various steps that are involved with building the Farm. Here is a diagram of the farm that we will build.
To get started read Automating Windows Azure Virtual Machines with PowerShell. Also if you are new to Azure Virtual Machines here is a crash course on the features that we will cover in the PowerShell scripts: Learn about Windows Azure Virtual Machines. With that out of the way let’s get started.
Create VNet
The first step is to create the virtual network. In the past the Cloud Service (previously called hosted services) was the container for multiple VMs to talk to each other. Now the Virtual Network (VNet) allows multiple Cloud Services to talk to each other. So in the case of our Farm we want the Active Directory/Domain Controller (AD/DC) to be in one Cloud Service and talk to the rest of our farm in another Cloud Service. By using 2 Cloud Services, you can start the AD/DC first and have the other Cloud Services join the domain, since we do not have static IPs. Here is the script to create the VNet.
CreateVnet.ps1
- # To get started
- # https://msdn.microsoft.com/en-us/library/windowsazure/jj156055.aspx
- CLS
- # List imported subscriptions
- # get-AzureSubscription | Select SubscriptionName
- # your imported subscription name
- $subscriptionName = "My Azure Subscription"
- $storageAccount = "2010storage"
- Select-AzureSubscription $subscriptionName
- Set-AzureSubscription $subscriptionName -CurrentStorageAccount $storageAccount
- # List all locations to determine $AGLocation
- #Get-AzureLocation | Select Name
- # Affinity Group parameters
- $AGLocation = "West US"
- $AGDesc = "SharePoint 2010 Affinity Group"
- $AGName = "SP2010-AG"
- $AGLabel = "SP2010-AG"
- # Create a new affinity Group
- New-AzureAffinityGroup -Location $AGLocation -Description $AGDesc `
- -Name $AGName -Label $AGLabel
- # Clear current settings
- Remove-AzureVNetConfig -ErrorAction SilentlyContinue
- # Apply new network
- $configPath = (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent) `
- + "SharePointFarmVNET.xml"
- Set-AzureVNetConfig -ConfigurationPath $configPath
- # Check results
- #Get-AzureVNetConfig | Select -ExpandProperty XMLConfiguration
- #Create Storage account for SP Farm
- # The storage account name must be unique to Windows Azure and
- # must be between 3 and 24 characters in length and
- # use lowercase letters and numbers only.
- #$storageAccountName = "sharepointfarm"
- #$label = "SharePoint Storage Account"
- #New-AzureStorageAccount -StorageAccountName $storageAccountName `
- # -Label $label -AffinityGroup $AGName
Create AD/DC
Once the VNet is in place you can create the Active Directory/Domain Controller. All this script does is create a VM in a Cloud Service. Once the VM is started you will need to manually RDP connect to the machine and run DCPROMO. Once DCPROMO is finished run ipconfig to determine the IP of the machine, which will be used in the Farm setup script.
CreateDC.ps1
- # To get started
- # https://msdn.microsoft.com/en-us/library/windowsazure/jj156055.aspx
- CLS
- # List imported subscriptions to determine $subscriptionName
- # get-AzureSubscription | Select SubscriptionName
- # List storage accounts to determine $storageAccount
- #Get-AzureStorageAccount | select StorageAccountName
- # your imported subscription name
- $subscriptionName = "My Azure Subscription"
- $storageAccount = "2010storage"
- Select-AzureSubscription $subscriptionName
- Set-AzureSubscription $subscriptionName -CurrentStorageAccount $storageAccount
- #List all images to determine $imagename
- #Get-AzureVMImage | Select ImageName
- #List Vnet config to determine $vnetname and $subnetname
- #Get-AzureVNetConfig | Select -ExpandProperty XMLConfiguration
- ## Domain Controller 1 Paramaters
- $vmName = 'SP2010-DC1'
- $imageName = 'MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd'
- $size = "ExtraSmall"
- $vmStorageLocation = "https://2010storage.blob.core.windows.net/vhds/SP2010Farm/SP2010-DC1.vhd"
- $deploymentName = "SP2010-DC1-Deployment"
- $deploymentlabel = "SharePoint 2010 DC1 Deployment"
- $subnet = 'SP2010AD-Subnet'
- $password = 'pass@word1'
- ## Create VM Configuration
- $dc1 = New-AzureVMConfig -Name $vmName -InstanceSize $size `
- -ImageName $imageName -MediaLocation $vmStorageLocation
- Add-AzureProvisioningConfig -Windows -Password $password -VM $dc1
- Set-AzureSubnet -SubnetNames $subnet -VM $dc1
- ## Cloud Service Paramaters
- $serviceName = "SP2010DC-Service"
- $serviceLabel = "SP2010DC-Service"
- $serviceDesc = "Domain Controller for SharePoint 2010"
- $vnetname = 'SP2010-VNET'
- $ag = 'SP2010-AG'
- ## Create the VM(s)
- New-AzureVM -ServiceName $serviceName -ServiceLabel $serviceLabel -ServiceDescription $serviceDesc `
- -AffinityGroup $ag -VNetName $vnetname -VMs $dc1
Create Farm
The last step is to create the SharePoint Farm.
CreateSPFarm.ps1
- # To get started
- # https://msdn.microsoft.com/en-us/library/windowsazure/jj156055.aspx
- CLS
- # List imported subscriptions to determine $subscriptionName
- # get-AzureSubscription | Select SubscriptionName
- # List storage accounts to determine $storageAccount
- #Get-AzureStorageAccount | select StorageAccountName
- # your imported subscription name
- $subscriptionName = "My Azure Subscription"
- $storageAccount = "2010storage"
- Select-AzureSubscription $subscriptionName
- Set-AzureSubscription $subscriptionName -CurrentStorageAccount $storageAccount
- # Cloud Service Paramaters
- $serviceName = "SP2010-Service"
- $serviceLabel = "SP2010-Service"
- $serviceDesc = "Cloud Service for SharePoint Farm"
- #List Vnet config to determine $vnetname and $subnetName
- #Get-AzureVNetConfig | Select -ExpandProperty XMLConfiguration
- # Gallery Images
- $spimage= 'MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd'
- $sqlimage = 'MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd'
- $vnetname = 'SP2010-VNET'
- $subnetName = 'SP2010Farm-Subnet'
- $ag = 'SP2010-AG'
- $primaryDNS = '192.168.1.4'
- # Availability Sets
- $avsetwfe = 'avsetwfe'
- $avsetapps = 'avsetapps'
- $avsetsql = 'avsetsql'
- # Domain Settings
- $domain = 'contoso'
- $joindom = 'contoso.com'
- $domuser = 'administrator'
- $dompwd = 'pass@word1'
- $advmou = 'OU=AzureVMs,DC=contoso,DC=com'
- # MediaLocation
- $mediaLocation = "https://2010storage.blob.core.windows.net/vhds/SP2010Farm/"
- ## Create SP WFE1
- $size = "ExtraSmall"
- $vmStorageLocation = $mediaLocation + "SP2010-WFE1.vhd"
- $spwfe1 = New-AzureVMConfig -Name 'SP-WFE1' -AvailabilitySetName $avsetwfe `
- -ImageName $spimage -InstanceSize $size -MediaLocation $vmStorageLocation |
- Add-AzureProvisioningConfig -WindowsDomain -Password $dompwd `
- -Domain $domain -DomainUserName $domuser -DomainPassword $dompwd `
- -MachineObjectOU $advmou -JoinDomain $joindom |
- Add-AzureEndpoint -Name 'http' -LBSetName 'lbhttp' -LocalPort 80 -PublicPort 80 `
- -Protocol tcp -ProbeProtocol http -ProbePort 80
Comments
- Anonymous
September 25, 2012
The comment has been removed - Anonymous
September 27, 2012
The comment has been removed - Anonymous
October 29, 2013
Please supply the content for - as I have no idea as to where to get this content and your well written script then fails for me. Are you able to supply? SharePointFarmVNET.xml Thanks. Jonathan Douglas