Running SharePoint 2013 on Windows Azure Virtual Machines

28/04/2013

Yesterday it was #GlobalWindowsAzure bootcamp day, and lots of attendees all over the world spent a day getting to know windows azure or improving their existing azure skills.

I attended the bootcamp in Copenhagen, and had a fun and inspiring day. I spent the day working with some topics I haven’t had a chance to play with, while preparing for certification 70-487: Developing Windows Azure and Web Services.

This was mainly the Windows Azure Virtual Machines in particular how to set them up for running SharePoint. It was in general a easy setup experience, and definitely an option for companies that want to be self-hosted but don’t want to invest in hardware.

Personally I have no plans on running anything 24×7 in azure on virtual machines, because the costs are a little steep for an individual, but for proof of concept and time scoped development tasks I would consider it. It cost me around 10$ to run my virtual machines for my one day testing alone, so not something I feel like paying for without a specific need.

Installation

I created 3 machines for my SharePoint environment (made from the premade VM images provided by Windows Azure)

In order to setup the domain controller I followed the guide Deploying Active Directory in Windows Azure (PowerShell) from the Windows Azure Training Kit. It was fairly easy to follow along I only encountered a few issues along the way. I will clarify those in the following.

Getting the publish.settings file

For some reason I wasn’t able to figure out where to get it from the management portal, luckily it is very easy to get with the Azure Powershell Cmdlets. Just type:

Get-AzurePublishSettings

And it will open the browser for you where you can login and download it.

Setting the AzureSubscription to use

This might not apply to everyone, but since I have two subscriptions linked to my live-id, the commands from the guide wasn’t working for me.
When you have multiple subscriptions you need to tell the Azure Powershell what subscription and storage account to use, the following cmdlets can be used, to give an overview and set it up.

#Set the subscription to work on
#Get-AzureSubscription
#Get-AzureStorageAccount
Set-AzureSubscription -SubscriptionName "Subscription-1" -CurrentStorageAccount "sjkpadlabstorage"

Creating the Virtual Machines

To create the virtual machine for the domain controller I used the following snipit from the guide:

$cloudsvc = 'some-unique-name'
$vmname1 = 'ad-dc'
$subnet = 'ADSubnet'
$vnet = 'ADVNET'
$pwd = '[YOUR-PASSWORD]'

New-AzureVMConfig -Name $vmname1 -InstanceSize Small -ImageName $imgname |
Add-AzureProvisioningConfig -Windows -Password $pwd |
Set-AzureSubnet -SubnetNames 'ADSubnet' |
Add-AzureDataDisk -CreateNew -DiskSizeInGB 20 -DiskLabel 'DITDrive' -LUN 0 |
New-AzureVM -ServiceName $cloudsvc -AffinityGroup 'adag' -VNetName 'ADVNET'

Getting the image names for all 3 of the machines I used Get-AzureVMImage | Select ImageName . Before I created the SQL and SP2013 machine, I finished the configuration of the domain controller and rebooted it. Creating the SQL and SP2013 machines where quite easy, again, I just used the snipit from the guide with the correct imagename, and when the machines came online they were correctly configured to be part of the domain.

# Point to IP Address of Domain Controller Created Earlier
$dns1 = New-AzureDns -Name 'ad-dc' -IPAddress '[Domain-Controller IP Address]'

# Configuring VM to Automatically Join Domain
$advm1 = New-AzureVMConfig -Name 'advm1' -InstanceSize Small -ImageName $imgname |
Add-AzureProvisioningConfig -WindowsDomain -Password '[YOUR-PASSWORD]' `
-Domain 'dev.sjkp.dk' -DomainPassword '[YOUR-PASSWORD]' `
-DomainUserName 'administrator' -JoinDomain 'dev.sjkp.dk' |
Set-AzureSubnet -SubnetNames 'AppSubnet'

# New Cloud Service with VNET and DNS settings
New-AzureVM -ServiceName '[SOMEUNIQUEAPPNAME]' -AffinityGroup 'adag' `
-VMs $advm1 -DnsSettings $dns1 -VNetName 'ADVNET'

Setting up SQL Server

After configuring the machines I thought I was ready to install SharePoint, but the SQL server needed a little configuration before that was possible. I had to do the following:

Configuring SharePoint 2013

The last part of my journey was to setup SharePoint 2013, I just did a standard GUI based configuration to test that it was working. After using my SP_Farm account and configuring the SQL server as described above I was able to finish the SharePoint installation and setup a single server test farm.

To open access to the farm from the outside, all you have to do is to add a TCP port 80 endpoint to your virtual machine, and setup alternate access mapping on the SharePoint server to match your dsn-name and wolla you can browse your windows azure hosted SharePoint 2013 server. You can use the *.cloudapp.net DNS name that windowsazure gives you, or you can configure a A record in your DNS server to point to the IP address of your server (I did the later), so I could get it access it on sp2013.sjkp.dk.
sp2013_azure

Performance

As you may have noticed all of my machines where running on small instances, which is nowhere near the recommended for running a SharePoint 2013 environment. Regardless of this browsing and using the teamsite I configured for my testing purpose was actually a pretty decent experience performance wise, so if you are willing to pay for the real Azure Metal, I’m sure you can host some large SharePoint installations in the cloud with no issues.

Shutting everything down

As I mentioned early it can get quite costly to have virtual machines running that you are not using, so remember to shut them down AND delete them. Remember it’s not enough to shut them down as you will still be billed until they are deleted, when you deleted them you don’t have to delete the associated storage, but you have to delete the actual VM.

So as long as you are willing to pay for the storage it’s fairly easy to start the machines up again. For shutting down and starting them up again I created the following two powershell scripts.
Export settings and delete virtual machines.

#Import publishsettings
#Export it Get-AzurePublishSettingsFile

Import-AzurePublishSettingsFile J:\azure\Subscription-1-Pay-As-You-Go-4-28-2013-credentials.publishsettings

#Set the subscription to work on
#Get-AzureSubscription
#Get-AzureStorageAccount
Set-AzureSubscription -SubscriptionName "Subscription-1" -CurrentStorageAccount "sjkpadlabstorage"

#export
#Export-AzureVM -ServiceName "sjkpsp2013" -Name advm1 -Path J:\Azure\vms\sjkpsp2013.xml

Get-AzureVM | foreach {
$path = 'j:\azure\vms\' + $_.Name + '.xml'
Export-AzureVM -ServiceName $_.ServiceName -Name $_.Name -Path $path
Remove-AzureDeployment -ServiceName $_.ServiceName -Slot Production -Force
}

Import and start virtual machines again

$vms = @()
Get-ChildItem 'j:\azure\vms\' | foreach {
$path = 'j:\azure\vms\' + $_
$vms += Import-AzureVM -Path $path
}
New-AzureVM -ServiceName 'sjkpVMs' -VMs $vms

That concludes my SharePoint 2013 running in Windows Azure Virtual Machines tour.