Lab management’s public interface is exposed at both web service layer and at the client SDK layer.

    The SDK can be used to script a bunch of stuff. To pen down a few :

  • To automate some maintenance tasks like cleaning up old environments, storing environments to library when the environments are not in use....
  • To retrieve the virtual machine related information like computer name, the host on which it is deployed..…
  • To write custom activities that can be used to tweak the out of box build-deploy-test workflow to suit your needs..

Here is a sample (attached the same) which will query for all active environments in a particular team project and delete the environments which were not accessed during last 30 days.

clip_image001

Few things to note :

  • In Beta2 bits, it is not possible to add reference to the lab assemblies through "Add reference" menu. In order to refer the lab SDK, open the .csproj file in notepad and add the assembly names under <ItemGroup> node.

    clip_image002

  • After editing the csproj file and saving it, include the following namespaces in the code :

    clip_image003

  • Most of the lab operations (creating an environment, deleting, storing, taking snapshot … )are asynchronous. Hence after invoking the appropriate method, make sure that you wait till the operation is complete.

    Example: In the above example, there is a wait to ensure that the environment delete operation is complete.

  • The properties of individual virtual machines in an environment can be accessed as below:

    clip_image004

    To get the computer name of a virtual machine use, "ls.ExtendedInfo.RemoteInfo.ComputerName".

Hope you find it useful. Thanks !