Hosting SharePoint in Azure – Creating Resources in Resource Groups

I was recently helping a customer to deploy SharePoint into Azure IaaS, one of their requirements was that all resources used by the SharePoint farm would be hosted within a single Azure Resource Group. If you are not familiar with Resource Groups I'd highly recommend reading the following article - Azure Resource Manager Overview.

This was my first experience of using Resource Groups so I set about having a play around to determine how I could create the following resources using PowerShell and place these into a single Resource Group for the SharePoint farm, this included:

  • The Cloud Service that was created to host the SharePoint farm
  • All of the SharePoint VMs
  • Storage Account used to store the VHDs for the VMs
  • Virtual Network that was created specifically for the SharePoint VMs

After much experimentation I discovered the following:

When creating a Cloud Service, a Resource Group is provisioned with the same name as the Cloud Service - this meant that once I created the Cloud Service I then had to figure out how to create/move the VMs, Storage Account and Virtual Network into this Resource Group.

This is the PowerShell that I used to create the Cloud Service (which in turn created the Resource Group):

#Create Azure Service
Write-Host "Creating Azure Service..." -ForegroundColor Green
New-AzureService -ServiceName "SharePointFarm" -Location "North Europe"

I then needed to create the Storage Account (as you can't create VMs without Storage!). Interestingly, you need to use Switch-AzureMode -name AzureResourceManager to use the PowerShell cmdlets for Resource Manager. Once I had done this, I could then create the Storage Account using New-AzureResourceGroupDeployment and the template that is provided by Resource Manager to create Storage Accounts. I needed to specify some parameters, such as the Resource Group name to create the Storage Account within, location and type of storage.

#Create Storage Account
Write-Host "Creating Storage Account..." -ForegroundColor Green
Switch-AzureMode -name AzureResourceManager
New-AzureResourceGroupDeployment -ResourceGroupName "SharePointFarm" -GalleryTemplateIdentity Microsoft.ClassicStorage.0.3.5-preview -nameFromTemplate SharePointFarmStorage -location "North Europe" -accountType "Standard_GRS" -diagnosticsMetricsLevel "none" -diagnosticsApiVersion "2014-04-01" -diagnosticsMetricsRetention "0"

Two down, two to go! Now I had to tackle the Virtual Network! Again, I used New-AzureResourceGroupDeployment, specifying values for the Location, Address Space, Subnet and Name of the Virtual Network.

#Create Virtual Network
Write-Host "Creating Virtual Network..." -ForegroundColor Green
Switch-AzureMode -name AzureResourceManager
New-AzureResourceGroupDeployment -ResourceGroupName "SharePointFarm" -GalleryTemplateIdentity Microsoft.VirtualNetwork.1.0.4 -location "North Europe" -addressSpaceCidr -subnetName SubNet1 -subnetCidr -nameFromTemplate SharePointNetwork

Last but not least, the VMs, this was the easy one. By creating the VMs within the SharePointFarm service, Azure automatically placed these within the Resource Group associated with the service - in this case SharePointFarm. I simply needed to use the ServiceName parameter with New-AzureVM, specifying the name of the Service to associate the VMs with.

Here is how it all looks in the new Azure Portal (Resource Groups aren't visible in the legacy Azure Portal).


Hopefully this will help if you run into a similar scenario!


Brendan Griffin - @brendankarl



Comments (0)

Skip to main content