After all of the previous blog posts, I thought that I would climax with a few real examples of using the DSC resource for XenDesktop.
Earlier this year (just a few++ weeks ago) Microsoft released the VM
extensions for Virtual Machines. This is the IaaS style VM role. The VM
Extensions are small modules that you can inject into your VM and you can
interface with them. The simplest way to think of it is they are purpose built
agents. You can configure them on provisioning, but also nifty is that you can
update the configuration of an extension after deployment and do something
There is a script extension that can be used to download and execute any
script(s) inside of your VM. Handy for performing a number of things. You can
use this to drive DSC if you like.
After that the DSC extension was released. This one is purpose built just
for DSC and the one this post will be focusing on.
I will warn you, I am going to expose a few warts of the process as I do
this, just because the extension is built to support DSC and only the DSC
packages. And this process requires external media - yes, the media could be
bundled into the DSC resource (the only workaround to this process at the
moment), but that would make the resource really fat. So, why not continue to
think of it as two problems.
One thing - the DSC provider for XenDesktop expects media to be on the
machine where it runs or a DVD attached ISO. So a ZIP or ISO (DVD attached or
downloaded to the machine) or folder. This way there is no requirement to save
credentials for connecting to some share or other store.
Now, let get everything set up. (I am experimenting with a slightly
different writing format here, so you will have to let me know if it works for
First of all, I am going to assume that you are sitting at your
'configuration computer' - that management computer that you use that has all of
the consoles and what not installed. In this case it is where you build all of
your configurations that you later push to machines or place on your pull
server. Your configuration computer needs the XenDesktop
resource module installed under the path
"%ProgramFiles%\WindowsPowerShell\Modules" so a later cmdlet for the DSC script
provider can automagically pick it up and bundle it for you.
Begin by connecting to your Azure subscription
and set the storage account you will be using (
Set-AzureStorageAccount -StorageAccountName "YourCoolStorageAccount" )
Then upload the XenDesktop media. ( the media is created
from the ISO, simply ZIP the contents of the ISO - don't add any folders into
For a later step
you will need the URI to the blob that you just uploaded.
Now, we need to define
the configuration (the DSC one) that will be applied to the VM.
For that I created a PowerShell script that accepts two
parameters; the URI to the media and the role to be installed.
The DSC extension will run this and then apply the configuration.
Now that the
configuration script exists, this must be packaged up, with the
module, for the Azure DSC extension to use. I saved mine with the name
The Azure PowerShell cmdlets have created a cmdlet just for this action;
running the Publish-AzureVMDscConfiguration cmdlet, go check out your Azure
management portal and look into the container and you will find a ZIP archive
with a name that matches your script. What the Public- command does is package
the script and the modules that are used into the ZIP, then uploads them to
Azure for you.
Now, define the VM, so that can be created.
First needed is an Azure VM Image - an 'image' is a virtual
disk that is installed with an OS and prepared with sysprep and registered with
Azure as an image - to the management platform, this means that it can
specialize the OS on provisioning through mini-setup and the use of an
unattended answer file.
First, begin with a base VM configuration.
Then add the provisioning configuration ( these are the specialization
Then configure the Azure DSC VM extension.
create the VM. Azure and the VM extension take care of
processing the configuration script, and the configuration script downloads the
ZIP, unpacks it, and installs the role.
One really cool
thing about DSC is that you can keep applying configurations. The last applied
settings to a specific thing win, configurations are not undone when a new one
is added, simply the changes defined in the new configuration are applied. So,
if you have some management layer, it can apply configuration after
configuration if it so wanted to, or change a configuration over time to modify
As an option for delivering media, you can use a data disk with the
XenDesktop media within it. Then you can attach that to a new VM and have DSC
mount the disk (rather, make sure it is mounted at a specific drive letter) and
then perform the installation.
If you are using SCVMM, you can have an ISO attached to the VM as part of the
template. You could even use DSC to map a drive if that is what fits for your
environment. They are all possibilities.
Have fun! And please, send feedback!