VN:F [1.9.22_1171]
Rat­ing: 5.0/5 (1 vote cast)

Tip #1: Grow­ing Your Share­Point Farm

So you have a bunch of servers in your farm but you need one or two more. The steps I out­lined before will work with some mod­i­fi­ca­tion. Now that you’ve already cre­ated your Cloud Ser­vice, you have to do things a bit dif­fer­ently. If you try to do the New-AzureVM com­mand like before, you’ll likely see “DNS name already taken” error that I’ve high­lighted fur­ther down. To add addi­tional servers to your Cloud Ser­vice, fol­low the guid­ance from the pre­vi­ous arti­cles about con­nect­ing to Win­dows Azure, spec­i­fy­ing your Cloud Ser­vice, stor­age account, and other per­ti­nent infor­ma­tion. Then define your new server or servers as we did before.

?View Code POWERSHELL
1
2
3
4
5
## Create SP App3 
$size = "Small"
$vhdname = "Arch-SPApp3.vhd" 
$vmStorageLocation = $mediaLocation + $vhdname
$spwebnew = New-AzureVMConfig -Name 'Arch-SPApp3' -AvailabilitySetName $avsetwfe -ImageName $spimage -InstanceSize $size -MediaLocation $vmStorageLocation | Add-AzureEndpoint -Name 'https' -LBSetName 'lbhttps' -LocalPort 443 -PublicPort 443 -Protocol tcp -ProbeProtocol http -ProbePort 80 -ProbePath '/healthcheck/iisstart.htm' | Add-AzureEndpoint -Name "RemoteDesktop" -Protocol TCP -PublicPort (get-random -max 65000 -min 20000) -LocalPort 3389 | Set-AzureSubnet $subnetName | Add-AzureProvisioningConfig -Password 'pass@word1' -Windows

The exam­ple I’m show­ing would cre­ate a new Win­dows server with­out Share­Point. Then here’s the part to really pay atten­tion to, the New-AzureVM command:

?View Code POWERSHELL
1
New-AzureVM -DeploymentName "NewSharePointServer" -ServiceName $serviceName -VNetName $vnetname -VMs $spwebnew

Here, we only need to give the –Ser­vi­ce­Name, –VNet­Name, and –VMs para­me­ters. If you put in more infor­ma­tion, espe­cially the Affin­i­ty­Group, you’ll get the DNS already taken error.

Tip #2: DNS name already taken

image thumb SharePoint on Windows Azure   10 Tips

If you get this, it usu­ally means this is the sec­ond time you’ve run the New-AzureVM for the Cloud Ser­vice. If every­thing is OK and you just want to add a server, see tip #1. If some­thing is wrong, remove the Cloud Ser­vice and try it (the New-AzureVM cmdlets) again:

?View Code POWERSHELL
1
Remove-AzureService -ServiceName "ArchSharePoint" -Force

Tip #3: Fin­ish Up

Remem­ber to cre­ate the healthcheck file. In our exam­ples, we spec­i­fied the –ProbePath ‘/healthcheck/iisstart.htm’. So, we need to go to each server that we want our Azure load bal­ancer to use and add that file. To do so, open IIS Man­ager and expand the Default Web Site. Right-click on the Default Web Site and select Add Vir­tual Direc­tory. Give it a name (Alias) of “healthcheck” and choose a path (I used C:\Inetpub\wwwroot). Finally copy the “iisstart.htm” from the root of Default Web Site to the healthcheck folder, or just cre­ate an empty file called “iisstart.htm” Here’s how it looks when its finished.

image thumb1 SharePoint on Windows Azure   10 Tips

Tip #4: Automate

If you’re going to be doing this repeat­edly (for exam­ple, to per­form a bunch of tests), auto­mate. Lucky for us, Ram Gopinathan has writ­ten a script to do just that: http://gallery.technet.microsoft.com/PowerShell-Script-for-f43bb414 Ram’s script using an input file so you can eas­ily doc­u­ment what you’re doing, then it pro­vi­sions all your VMs. After you’re done, it’ll tear every­thing down, nice and neatly.

Tip #5: CSU­pload Error: Too many argu­ments for com­mand Add-Disk

This error occurred when using Add-Disk:

image thumb2 SharePoint on Windows Azure   10 Tips

The prob­lem was the — (the dashes). I used notepad, Pow­er­GUI and other tools, but the dash doesn’t trans­late to the com­mand prompt. To resolve this, just re-type the dashes.

Tip #6: CSU­pload Error: CSU­pload is expect­ing a page blob

I had copied down a vhd to make some mod­i­fi­ca­tions and then tried to upload it later. Here’s what I kept getting:

image thumb3 SharePoint on Windows Azure   10 Tips

In fact, CloudX­plorer and other tools I tried reported the same thing. What’s the fix? Use AzCopy. See the link to read up on how to get it. AzCopy is great because it can multi-thread. My uploads using AzCopy were very fast. By spec­i­fy­ing the /BlobType:page para­me­ter, you can upload a block blob as a page blob. Here’s how my com­mand looks: azcopy E:\ftproot\vhd http://storageacct.blob.core.windows.net/vhds/ /blobtype:page /destkey:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxx/== /Z /V

Tip #7: No Remot­eDesk­top Endpoint

I also real­ized that none of my VMs had an end­point for Remote Desk­top. We can add that by using a com­mand like this:

?View Code POWERSHELL
1
2
$vmname = "Arch-SQL1"
Get-AzureVM -ServiceName "ArchSharePoint" -Name $vmname | Add-AzureEndpoint -Name "RemoteDesktop" -Protocol "TCP" -PublicPort 53223 -LocalPort 3389 | Update-AzureVM

Remem­ber to use a dif­fer­ent Pub­lic­Port for each VM in a par­tic­u­lar Cloud Ser­vice. I just incre­mented by one (53223, 53224, etc.). Or, this should work too:

?View Code POWERSHELL
1
Get-AzureVM -ServiceName $servicename | ForEach-Object {Add-AzureEndpoint -Name $endpointname -Protocol TCP -PublicPort (get-random -max 65000 -min 20000) -LocalPort 3389} | Update-AzureVM

I under­stand that it’s pos­si­ble, but not likely, Get-Random could pick the same ran­dom num­ber. I sup­posed you could script it fur­ther to check if a port is being used but that wasn’t worth the effort here.

Tip #8: Office Web Apps Tip

I pub­lished my Share­Point farm pub­licly, by cre­at­ing an end­point at 443. This allows me to browse Share­Point from any­where using https://.cloudapp.net. How­ever, I couldn’t use my Office Web App servers since they were only acces­si­ble from within Azure. The Office Web Apps were con­fig­ured to use https and run on port 443. I could pub­lish an end­point, but I had already used 443 for Share­Point (and I don’t want to use an inse­cure port, like 80). So, I picked a ran­dom port, 9443. Now, how do we get Share­Point to know about this? Share­Point will PULL infor­ma­tion from Office Web Apps, so first we need to con­fig­ure Office Web Apps with this infor­ma­tion (do this on any Office Web Apps server):

?View Code POWERSHELL
1
2
# Set the ExternalUrl on any Office Web Apps Server
New-OfficeWebAppsFarm -ExternalUrl https://archsharepoint.cloudapp.net:9443

Then, on the Share­Point server, New-SPWopiBinding will bind to the pub­lic address on the pub­lic port (https://archsharepoint.cloudapp.net:9443). Cre­ate an end­point in the WAC server for a TCP con­nec­tion on pub­lic port 9443 to pri­vate port 443.

Tip #9: Blocked RDP in Firewall

Dur­ing test­ing of ports and pro­to­cols, I blocked all con­nec­tions on one of my servers. Obvi­ously, that included the RDP port. If you do that, the only thing you can really do is down­load the VHD for that server, mount it on-premises some­where (which will give you con­sole access) and change it. Then, upload it back to Win­dows Azure. It’s a tedious process, so if you really don’t need machine or data, re-create it.

Tip #10: Reduce costs

UPDATE: 6/10/2013

As of June 3rd, we are no longer billed for VMs in a stopped state, great news! See Scott Guthrie’s Blog for more info.

If you’re test­ing sce­nar­ios over a period of week or months and you don’t nec­es­sar­ily use your VM’s every day — you can cut some costs. For some of my work, I might go a week or two with­out ever log­ging in to my Share­Point farms in Win­dows Azure. All the while though, you’re being charged for com­pute hours. The only way to stop that is to delete your VMs. Pow­er­ing down doesn’t cut your costs, you’re still charged for com­pute hours. You can use tip #4 to do a com­plete “tear down,” or use some Pow­er­Shell snip­pets to do a par­tial tear down. I’ll show you an exam­ple that should be pretty easy to fol­low. First, we’ll backup our VM configs:

?View Code POWERSHELL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Region Func: BackupVMConfigs
function BackupVMConfigs () 
{
	param
    (
        [Parameter(Mandatory=$True)][ValidateNotNullOrEmpty()]
        [String]$CloudService,
        [Parameter(Mandatory=$True)][ValidateNotNullOrEmpty()]
        [String]$Folder
	)
If (Get-AzureVM -ServiceName $cloudservice) 
	{
		Write-Host "Backing up SharePoint VM Configurations..."
		Try {
			Get-AzureVM -ServiceName $cloudservice | foreach {
			$path = $folder + $_.Name + '.xml'
			Export-AzureVM -ServiceName $cloudservice -Name $_.Name -Path $path 
			}
			}
		Catch 
			{
			Write-Output $_
			Throw " - Error occurred. Not continuing since VM configuration may not have been saved and we don't want to delete them."
			}	
	}
Else { Write-Host " - Skipping $cloudservice because it doesn't seem to exist." -ForegroundColor Yellow}
Write-Host "- Done backing up. Removing VM's from Cloud Service..." -ForegroundColor Yellow
}
#EndRegion

To use that func­tion, you’d type in Back­upVM­Con­fig –Cloud­Ser­vice ” –Folder “ ” I’ve used that func­tion in the next snip­pet, where we actu­ally remove the Cloud Service/Deployment:

?View Code POWERSHELL
1
2
3
4
5
6
7
8
9
#Region Func: Remove SP Deployment
function RemoveSP {
$CloudService = "ArchSharePoint"
BackupVMConfigs -CloudService $CloudService -Folder "C:\Scripts\Azure\SharePoint\"
#Removing all VMs while keeping the cloud service/DNS name
Remove-AzureDeployment -ServiceName $cloudservice -Slot Production -Force
Write-Host "Removed all SharePoint VMs"
}
#EndRegion

Once you run the “RemoveSP”; func­tion, you’re no longer incur­ring com­pute charges. The actual VHD’s are still there in your Win­dows Azure stor­age account though. The charges for stor­age are very small, almost insignif­i­cant so we keep those there. Later, when you’re ready to fire up your farm you can do the inverse. First, I have a func­tion to do the actual import of the VMs:

?View Code POWERSHELL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#Region Func: ImportVMs ($CloudService, $Folder)
function ImportVMs ()
{
	param
    (
        [Parameter(Mandatory=$True)][ValidateNotNullOrEmpty()]
        [String]$CloudService,
        [Parameter(Mandatory=$True)]
		[ValidatePattern({\\$})]
		[ValidateScript({Test-Path $_ -PathType 'Container'})] 
        [String]$Folder
	)
$cs = Get-AzureVM -ServiceName $cloudservice
If ($cs.Count -ge 1) 
	{
	Write-Host "It looks like (at least some) of the VMs are up. Skipping restore..." -ForegroundColor Green
	}
Try 
	{
	Write-Host " - Importing VMs..." -ForegroundColor Yellow
	$script:vms = @()
	Get-ChildItem $folder | foreach {
		$path = $folder + $_
		$script:vms += Import-AzureVM -Path $path
		}
	}
Catch
	{
	Write-Output $_
	Throw " - Error occurred."
	}	
}
#EndRegion

And here’s where I’m using it:

?View Code POWERSHELL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#Region Restore SharePoint Deployment
function RestoreSharePoint 
{
$cloudservice = "ArchSharePoint"
$folder = "C:\Scripts\Azure\SharePoint\" #must include trailing \
ImportVMs -CloudService $CloudService -Folder $Folder
Write-Host " - Restoring takes about 30 minutes..." -ForegroundColor Yellow
Measure-Command {New-AzureVM -ServiceName $cloudservice -VNetName "vNet-Arch" -VMs $vms}
}
<# 
#This is used if the Cloud Service was deleted
## Cloud Service Paramaters  
$serviceLabel = $cloudservice
$serviceDesc = "Architecture SharePoint Farm" 
$ag = 'AG-SharePoint-Arch'
Measure-Command {New-AzureVM -ServiceName $cloudservice -ServiceLabel $serviceLabel -ServiceDescription $serviceDesc -AffinityGroup $ag -VNetName $vNet -VMs $vms}
#>
#EndRegion

Run­ning the “Restore­Share­Point” func­tion will call the ImportVMs func­tion with the right para­me­ters and attach your VHDs to some shiny new VMs based on the back­ups you took before.

Con­clu­sion

That’s the end of our series. I hope I’ve achieved my goal of con­sol­i­dat­ing all the infor­ma­tion needed to under­stand and setup Share­Point farms on Win­dows Azure IaaS. If you haven’t started play­ing around yet, go back to the intro­duc­tion to learn how to sign up for a free account. A big thanks to my col­leagues who helped me through­out the series: Paul Stubbs, Len Car­di­nal, Kosma Zygouras, Shane Laney.

{ 0 comments }