Windows Azure Pack: VM Clouds Automation: How it works ?

Hi all,

I’m here to continue my series about the automation with Windows Azure Pack.

In my last blog, i described the general mechanism to achieve automation actions related to virtual machine deployment in Windows Azure Pack.

So let me explain the end to end process of automation : I will use the “Create new Standalone VM” example

1- The tenant decides to create a new standalone virtual machine

2- The tenant validates the “Create Virtual Machine” wizard

3- In a WAP/SMA language, the “Create” “VMM Virtual Machine” action is called

4- in the meanwhile, the Create Virtual Machine process is triggered via SPF to VMM.  SPF tells VMM to create the VM

So, what have we here ?

Like everyone can notice it, in step 3, something was called by Windows Azure Pack. We will use this to achieve automation.

Our goal is to run a script (a workflow in SMA language) when an action is triggered.

Here is the complete list of the actions that we can link to a runbook (A powershell script, workflow), you can find almost all the possible actions : Create standalone VM, Create VM role, scale Up a VM role, Delete a standalone VM…

The following table resumes the Create/Delete VM actions:


NB: Till today, i have an issue triggering the action related to a “VM Role instance deletion”, i’m in touch with Microsoft to solve this issue, and will update this blog as soon as i have an update.

So if you join my first blog and this one you will say: I have a powershell script (A workflow, or a runbook) that i want it to be executed when creating a virtual machine.So I have to create the script, import it to Windows Azure Pack, then tell Windows Azure Pack to run this script every time a VM is created ie an Object=VMM Virtual Machine, Action = Create is called.

This is it! Now in the next blogs we will go deeper and make a step by step to achieve this, practically.

We will define a goal: I want that every time a new Standalone Virtual Machine is created, a checkpoint is created for this VM. Note that once you understand the tricks, you can do a lot of things than that just creating a snapshot: You can send emails telling the tenant that its VM has been provisioned, you can create a Replica for this VM or you can enable backup for this VM, any thing you can script 🙂

The following are the steps:

1- Create a script that takes as input the VMID and creates a checkpoint as output. Note that we will use the VMID and not the Virtual Machine name because the VMID is the unique identifier of a VM, and that multiple VMs can have the same name in Hyper-V (Hyper-V supports similar VM names)

2- Understand how to deal with runbooks in Windows Azure Pack and SMA : Syntax, Import runbooks, call a runbook from another runbook

3- Learn how to extract important data from a WAP action: For example how to catch the VM Name or the VMID and pass it to the script, we will manipulate the $PSPrivateMetaData SMA variable (Very important)

4- Use 1, 2 and 3 now to finalize our goal: catch the VMID (3) and run the script (1). We will also use a trick (2)

5- Test our runbook

After these 5 blogs, you will be able to deal with SMA runbooks and VM Clouds automation 🙂