This is the third blog post on the subject of creating and deploying a SharePoint farm in Windows Azure. The previous two are:
- In this post we will create an image that can be used when creating virtual machines. The advantage of this is, that it gives you the ability to “pack” the image/disk, both with software (installed or just the binaries) and – in our case – with an extended OS-disk.
- I assume that you have followed the initial steps and created the VNET, the storage account and the affinity group.
- We will use one of the images supplied in the gallery. To get the available images, submit the following command from a Windows Azure PowerShell prompt:
Get-AzureVMImage | Select ImageName
This will give you something similar to:
The name of the VM, Cloud Service and VHD-disk in the script below is not important as we will delete them later.
# Your Storage account
$storageAccount = “mystorageaccount”
# Your subscription name
$subscriptionName = “MySubscription“
Select-AzureSubscription $subscriptionName
Set-AzureSubscription $subscriptionName -CurrentStorageAccount $storageAccount
# VM Paramaters
$imageName = “a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-Datacenter-201301.01-en.us-30GB.vhd”
$size = “Small”
$mediaLocation = “http://mystorageaccount.blob.core.windows.net/vhds/”
$subnet = “SP-AppSubnet”
$password = “P@ssw0rd” # This will be the password for the VM
$vmName = “sp-base”
$vmStorageLocation = $mediaLocation + “sp-base.vhd”
$bi = New-AzureVMConfig -Name $vmName ‘
-InstanceSize $size -ImageName $imageName ‘
-MediaLocation $vmStorageLocation
Add-AzureProvisioningConfig -Windows -Password $password -VM $bi
Set-AzureSubnet -SubnetNames $subnet -VM $base
# Cloud Service Paramaters
$serviceName = “BaseServiceImage”
$serviceLabel = “BaseServiceImage”
$serviceDesc = “Base Image. Will be deleted”
$ag = “SP-AG”
# Create the Base VM
New-AzureVM -ServiceName $serviceName ‘
-ServiceLabel $serviceLabel ‘
-ServiceDescription $serviceDesc `
-AffinityGroup $ag -VMs $bi
We now have a plain VM running Windows Server 2012.
The following will be displayed in the PowerShell windows
If you log on to the management portal you will see the new VM under virtual machines. I have removed the name of the subscription due to certain confidentiality considerations, hence the black bar.
Next step is to extend the disk.
First we need to delete the VM just created. Ensure it is selected and then click Delete from the bottom menu.
and confirm
The system will begin to remove the VM.
and after a short while
Next step is to delete the disk.
Select Disk from the top menu
If the delete process is not completed you will see that the VM is still having a lease on the disk
Wait until the lease has expired
Delete the disk, but retail the VDH-file. This is very important as this is the one we wish to extend.
If you look in your storage account under the container vhds you can see, that the VHD-file is still there
Maarten Balliauw has created a small utility that will change the header information on the VHD-file allowing us to extend it. The maximum size is 127 GB; we will make it 100 GB.
Download the WindowsAzureDiskResizer tool from GitHub.
The syntax is the following:
You can get the accountname and accountkey from the storage page in the management portal.
As stated previously I set the size to 100
Before the tool was executed the VHD-file looked like this. Notice the size.
After running the tool the picture is the following:
Next step is to create an image using the VDH-file.
Select Images from the top menu under Virtual Machines.
and then click Create in the bottom menu
Enter a name and browse to the sp-base.vhd file
You need to check the “I have run Sysprep” even though that is not the case.
When the process is complete you can see the new image is available
We now want to create a new VM based on this new image, extend the disk from the Disk Manager, copy any software onto the disk or install it and when capture that VM.
I will show how this is done using the management portal, but you could amend the script above and just set the image name to
$imageName = “spbaseimage”
Select Virtual Machine Instances from the top menu
and then New from the bottom one.
You want to create a new VM from the gallery
Using your new image (the other two images are some I have created previously)
Give the VM a name, password and select the size
Give the VM a public facing DNS name and place it in the VNET. As we are actually not going to use this VM for anything other than begin the “template” for further work, it is more to ensure it is placed in our storage account.
Click OK to kick off the creating process.
Once the VM has been provisioned you want to open a Remote Desktop session (RDP) and log into it.
Enter the Disk Management
You can see the “original” 30 GB and the new unallocated 70 GB
Right click on C and select Extend Volume.
This will open up the Extend Volume Wizard.
Click Next.
Select the disk and the maximum size
and click Next again.
Click Finish to complete the wizard.
You now have a single OS volume of 100 GB.
The final step is to run Sysprep.
This is usually found in C:\Windows\System32\sysprep
Remember to set the Shutdown Option to Shutdown.
Press OK.
You can now Capture the VM. Select it and click Capture from the bottom menu. The VM has to be stopped before you can select the menu item.
Give the image a name and select the Sysprep option.
This turned out to be quite a long post.
In the next one in the series we will create the virtual machines for the two domain controllers and look at how to promote them to DCs.