Share via


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.

image

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

  1. # To get started
  2. # https://msdn.microsoft.com/en-us/library/windowsazure/jj156055.aspx
  3.  
  4. CLS
  5.  
  6. # List imported subscriptions
  7. # get-AzureSubscription | Select SubscriptionName
  8.  
  9. # your imported subscription name
  10. $subscriptionName = "My Azure Subscription"
  11. $storageAccount = "2010storage"
  12. Select-AzureSubscription $subscriptionName
  13. Set-AzureSubscription $subscriptionName -CurrentStorageAccount $storageAccount
  14.  
  15. # List all locations to determine $AGLocation
  16. #Get-AzureLocation | Select Name
  17.  
  18. # Affinity Group parameters
  19. $AGLocation = "West US"
  20. $AGDesc = "SharePoint 2010 Affinity Group"
  21. $AGName = "SP2010-AG"
  22. $AGLabel = "SP2010-AG"
  23.  
  24. # Create a new affinity Group
  25. New-AzureAffinityGroup -Location $AGLocation -Description $AGDesc `
  26.                                         -Name $AGName -Label $AGLabel
  27.  
  28. # Clear current settings
  29. Remove-AzureVNetConfig -ErrorAction SilentlyContinue
  30.  
  31. # Apply new network
  32. $configPath = (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent) `
  33.                     + "SharePointFarmVNET.xml"
  34.  
  35. Set-AzureVNetConfig -ConfigurationPath $configPath
  36.  
  37. # Check results
  38. #Get-AzureVNetConfig | Select -ExpandProperty XMLConfiguration
  39.  
  40. #Create Storage account for SP Farm
  41.  
  42. # The storage account name must be unique to Windows Azure and
  43. # must be between 3 and 24 characters in length and
  44. # use lowercase letters and numbers only.
  45.  
  46. #$storageAccountName = "sharepointfarm"
  47. #$label = "SharePoint Storage Account"
  48. #New-AzureStorageAccount -StorageAccountName $storageAccountName `
  49. # -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

  1. # To get started
  2. # https://msdn.microsoft.com/en-us/library/windowsazure/jj156055.aspx
  3.  
  4. CLS
  5.  
  6. # List imported subscriptions to determine $subscriptionName
  7. # get-AzureSubscription | Select SubscriptionName
  8.  
  9. # List storage accounts to determine $storageAccount
  10. #Get-AzureStorageAccount | select StorageAccountName
  11.  
  12. # your imported subscription name
  13. $subscriptionName = "My Azure Subscription"
  14. $storageAccount = "2010storage"
  15. Select-AzureSubscription $subscriptionName
  16. Set-AzureSubscription $subscriptionName -CurrentStorageAccount $storageAccount
  17.  
  18. #List all images to determine $imagename
  19. #Get-AzureVMImage | Select ImageName
  20.  
  21. #List Vnet config to determine $vnetname and $subnetname
  22. #Get-AzureVNetConfig | Select -ExpandProperty XMLConfiguration
  23.  
  24.  
  25. ## Domain Controller 1 Paramaters
  26. $vmName = 'SP2010-DC1'
  27. $imageName = 'MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd'
  28. $size = "ExtraSmall"
  29. $vmStorageLocation = "https://2010storage.blob.core.windows.net/vhds/SP2010Farm/SP2010-DC1.vhd"
  30. $deploymentName = "SP2010-DC1-Deployment"
  31. $deploymentlabel = "SharePoint 2010 DC1 Deployment"
  32. $subnet = 'SP2010AD-Subnet'
  33. $password = 'pass@word1'
  34.  
  35. ## Create VM Configuration
  36. $dc1 = New-AzureVMConfig -Name $vmName -InstanceSize $size `
  37.     -ImageName $imageName -MediaLocation $vmStorageLocation
  38. Add-AzureProvisioningConfig -Windows -Password $password -VM $dc1
  39. Set-AzureSubnet -SubnetNames $subnet -VM $dc1
  40.  
  41. ## Cloud Service Paramaters
  42. $serviceName = "SP2010DC-Service"
  43. $serviceLabel = "SP2010DC-Service"
  44. $serviceDesc = "Domain Controller for SharePoint 2010"
  45. $vnetname = 'SP2010-VNET'
  46. $ag = 'SP2010-AG'
  47.  
  48. ## Create the VM(s)
  49. New-AzureVM -ServiceName $serviceName -ServiceLabel $serviceLabel -ServiceDescription $serviceDesc `
  50.                         -AffinityGroup $ag -VNetName $vnetname -VMs $dc1

Create Farm

The last step is to create the SharePoint Farm.

CreateSPFarm.ps1

  1. # To get started
  2. # https://msdn.microsoft.com/en-us/library/windowsazure/jj156055.aspx
  3.  
  4. CLS
  5.  
  6. # List imported subscriptions to determine $subscriptionName
  7. # get-AzureSubscription | Select SubscriptionName
  8.  
  9. # List storage accounts to determine $storageAccount
  10. #Get-AzureStorageAccount | select StorageAccountName
  11.  
  12. # your imported subscription name
  13. $subscriptionName = "My Azure Subscription"
  14. $storageAccount = "2010storage"
  15. Select-AzureSubscription $subscriptionName
  16. Set-AzureSubscription $subscriptionName -CurrentStorageAccount $storageAccount
  17.  
  18. # Cloud Service Paramaters
  19. $serviceName = "SP2010-Service"
  20. $serviceLabel = "SP2010-Service"
  21. $serviceDesc = "Cloud Service for SharePoint Farm"
  22.  
  23. #List Vnet config to determine $vnetname and $subnetName
  24. #Get-AzureVNetConfig | Select -ExpandProperty XMLConfiguration
  25.  
  26. # Gallery Images
  27.   $spimage= 'MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd'
  28. $sqlimage = 'MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd'
  29. $vnetname = 'SP2010-VNET'
  30. $subnetName = 'SP2010Farm-Subnet'
  31. $ag = 'SP2010-AG'
  32. $primaryDNS = '192.168.1.4'
  33.  
  34. # Availability Sets
  35. $avsetwfe = 'avsetwfe'
  36. $avsetapps = 'avsetapps'
  37. $avsetsql = 'avsetsql'
  38.  
  39. # Domain Settings
  40. $domain = 'contoso'
  41. $joindom = 'contoso.com'
  42. $domuser = 'administrator'
  43. $dompwd = 'pass@word1'
  44. $advmou = 'OU=AzureVMs,DC=contoso,DC=com'
  45.  
  46. # MediaLocation
  47. $mediaLocation = "https://2010storage.blob.core.windows.net/vhds/SP2010Farm/"
  48.  
  49. ## Create SP WFE1
  50. $size = "ExtraSmall"
  51. $vmStorageLocation = $mediaLocation + "SP2010-WFE1.vhd"
  52. $spwfe1 = New-AzureVMConfig -Name 'SP-WFE1' -AvailabilitySetName $avsetwfe `
  53.             -ImageName $spimage -InstanceSize $size -MediaLocation $vmStorageLocation |
  54.         Add-AzureProvisioningConfig -WindowsDomain -Password $dompwd `
  55.             -Domain $domain -DomainUserName $domuser -DomainPassword $dompwd `
  56.             -MachineObjectOU $advmou -JoinDomain $joindom |
  57.         Add-AzureEndpoint -Name 'http' -LBSetName 'lbhttp' -LocalPort 80 -PublicPort 80 `
  58.             -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