General availability of Azure DevTest Labs – VSTS extension


A couple of weeks ago, we announced the general availability of Azure DevTest Labs: your self-service sandbox environment in Azure to quickly create Dev/Test environments while minimizing waste and controlling costs. As part of the announcement we introduced the preview of Azure DevTest Labs – VSTS extension. Today, we are delighted to announce the general availability of the extension. It consists of three tasks that will allow you to easily integrate your build or release pipeline in VSTS with DevTest Labs to create your testing environment, golden images, and more!

Figure1

Figure 1: Azure DevTest Labs – VSTS extension

 

One of the key scenarios that we have addressed with the extension is the “golden image” scenario. You want developers/testers to quickly create a virtual machine in the lab with the latest build of your application already installed so that they don’t waste time in installing the latest build and can quickly get started with the testing of the latest build in minutes.

The extension makes it very easy for you by offering three tasks that you can use in your build or release pipeline in VSTS.

Figure2

Figure 2: Azure DevTest Labs – VSTS Tasks

You can use the “Azure DevTest Labs Create VM” task to create a lab VM. You can use the existing VSTS tasks such as “Azure File Copy” or “PowerShell on Target Machines” to install the latest build. Then, you can save the lab VM as custom image using the “Azure DevTest Labs Create custom image” task. Finally, you can use the “Azure DevTest Labs Delete VM” task to delete the lab VM. The custom image created in the lab is shared with all the lab users and they can use the custom image to create a new VM for their testing.

Let’s look at each of the steps involved in the golden image scenario in detail.

Create a lab VM using “Azure DevTest Labs Create VM” task

  • The task takes an Azure resource manager (ARM) template from the drop location to create a lab VM. You can easily generate a lab VM ARM template in your lab through the “Create VM” workflow. Go to the lab –> Click “+ Virtual Machine” –> enter the required fields –> Click “View ARM Template” 
    Figure3

          Figure 3: Generate an ARM template in the lab

  • Change the ARM template to configure WinRM on the lab VM so that other VSTS tasks such as “Azure File Copy” or “PowerShell on Target Machines” can talk to the lab VM to perform an action on the VM. Tarun Arora is a Microsoft MVP in Visual Studio Development Tools and has written a very nice blog about it. You can check out his blog here.
  • Copy the ARM template and save it in your VSTS source control.
    Figure4

 

 

 

 

           

 

          Figure 4: Save the ARM template in source control

  • Configure the task by selecting a subscription, selecting the lab, entering the path of the ARM template that you saved in the source control and finally passing the parameters that are required to create the VM. Don’t forget to enter the name of the variable that will store the Lab VM ID after the VM will be created in the lab. You can use the variable in other VSTS tasks to perform an action on the lab VM. Lab VM ID contains a value in the form /subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualMachines/{vmName}.

Figure5
Figure 5: “Azure DevTest Labs Create VM” task configuration

 

Install the latest build using VSTS tasks such as “Azure File Copy” or “PowerShell on Target Machines”

“Azure File Copy” task requires the name of the lab VM and the resource group of the lab VM. “PowerShell on Target Machines” task requires the fully qualified domain (FQDN) name of the lab VM or the public IP address of the lab VM.

You can run a PowerShell script using the “Azure PowerShell script” task to get the resource group, FQDN and public IP address of the lab VM and store them into variables so that you can refer the variables in other VSTS tasks. You can pass the Lab VM ID variable that is instantiated after the lab VM is created in the first step as argument to the PowerShell script.

Sharing a sample script that you can leverage:

Param(

[string]$labVmId

)

$labVmComputeId = (Get-AzureRmResource -Id $labVmId).Properties.ComputeId

 # Get lab VM resource group name

$labVmRgName = (Get-AzureRmResource -Id $labVmComputeId).ResourceGroupName

# Get the lab VM Name

$labVmName = (Get-AzureRmResource -Id $labVmId).Name

#Get lab VM public IP address

$labVMIpAddress = (Get-AzureRmPublicIpAddress -ResourceGroupName $labVmRgName –Name $labVmName).IpAddress

 #Get lab VM FQDN

$labVMFqdn = (Get-AzureRmPublicIpAddress -ResourceGroupName $labVmRgName -Name $labVmName).DnsSettings.Fqdn

# Set a variable labVmRgName to store the lab VM resource group name

Write-Host ##vso[task.setvariable variable=labVmRgName;]$labVmRgName

# Set a variable labVMIpAddress to store the lab VM Ip address

Write-Host ##vso[task.setvariable variable=labVMIpAddress;]$labVMIpAddress

# Set a variable labVMFqdn to store the lab VM FQDN name

Write-Host ##vso[task.setvariable variable=labVMFqdn;]$labVMFqdn

 

Figure6

Figure 6: Run Azure PowerShell task to get lab VM details

 

Save the lab VM as custom image using the “Azure DevTest Labs Create custom image” task.  

You can use the variable that you have defined in the first step to store the lab VM Id. Enter the variable name in the “Source Lab VM ID” parameter of the task to save the VM as image in the lab.

Figure7

Figure 7: “Azure DevTest Labs Create Custom Image” task configuration

 

Delete the lab VM using the “Azure DevTest Labs Delete VM” task.

Again, you can use the variable that you have defined in the first step to store the lab VM Id. Enter the variable name in the “Lab VM ID” parameter of the task to delete the lab VM.

Figure8

Figure 8: “Azure DevTest Labs Delete VM” task configuration

 

This is our first attempt to help you to easily integrate your VSTS build/release pipeline with Azure DevTest Labs. I am sure there is a scope of improvement. Please try out the extension and if you have any suggestions on how we can improve the extension, please do not hesitate to create a suggestion at the DevTest Labs feedback forum

If you run into any problems with the extension or have any questions, we are ready at the MSDN forum to help you.

Comments (6)

  1. Tarun__Arora says:

    Fantastic feature, one we have been waiting for… Excellent extension and integration with VSTS. Looking forward to more innovation in this space.

  2. Ankit says:

    Nice Information , will definitely help first time users!!

  3. Vince Agwada says:

    Hi,
    I am experiencing issues creating a lab VM. I have created a thread in the forum here: https://social.msdn.microsoft.com/Forums/en-US/1eca5049-5175-45ed-8d21-4c474a12f8a4/error-creating-devtest-labs-vm-from-vsts-build-a-parameter-cannot-be-found-that-matches-parameter?forum=AzureDevTestLabs

    My question is whether or not we would be able to get support for this through our MSDN subscription or is support only available through the forum?

    Thanks,

    –Vince

    1. Xiaoying Guo says:

      Hi Vince,

      Thanks for reporting the issue. You can get the support either from MSDN forum or by sending a service request from Azure portal using your MSDN subscription (as long as there’s a support plan). Our support team monitors both.

      Thanks
      Xiaoying

  4. Nice post. I used to be checking constantly this blog and I’m impressed!
    Very helpful information specifically the closing phase :
    ) I handle such information a lot. I was seeking
    this certain information for a very long time.
    Thanks and good luck.

  5. It’s amazing in support of me to have a web site, which is
    useful for my experience. thanks admin

Skip to main content