Leave a comment

Visual Studio Code Artifact for Azure DevTest Lab Service

Have you seen the Azure DevTest Lab service preview announcement?

From the service documentation:

Azure DevTest Lab is a service that helps developers and testers quickly create environments in Azure while minimizing waste and controlling cost. You can test the latest version of your application by quickly provisioning Windows and Linux environments using reusable templates and artifacts. Easily integrate your deployment pipeline with DevTest Lab to provision on-demand environments. Scale up your load testing by provisioning multiple test agents, and create pre-provisioned environments for training and demos.

Within this service, you can deploy virtual machines from a base image and then quickly deploy applications that are required for the developers or testers. You can set limits on how many VMs they can create and put policies on how long these VMs should be running and so on.

One of the concepts of DevTest Lab service that helps application deployment and configuration inside the lab VMs is the artifacts.

Artifacts are used to deploy and configure your application after a VM is provisioned. Artifacts can be:

  • Tools that you want to install on the VM – such as agents, Fiddler, and Visual Studio.
  • Actions that you want to run on the VM – such as cloning a repo.
  • Applications that you want to test.

artifactAnd, you can create custom artifacts and put them in your artifact repository for your users to attach them to VMs being deployed. There are already a bunch of them available. And, it isn’t difficult to create a new custom artifact. In fact, I created the custom artifact for installing Visual Studio Code in less than 10 minutes. There are few things we need. One is a JSON file that describes the artifact and the command to run when this artifact is attached to the VM. Internally, custom script extension is used to run the commands you specify here. The second thing we need is any automation (PowerShell scripts or shell scripts) for doing application installation and configuration.

Visual Studio Code Download and Install

I wrote a simple PowerShell script that downloads and install Visual Studio Code on Windows Systems.

This is straightforward and self-explanatory. Line 17 has the VS Code download URL which redirects to the VSCodeSetup.exe. Once we have this downloaded, we install it using the silent install parameters. I am using an inf file to pass the install parameters. Here are the contents of that file.

Artifact JSON

The next thing we need is the artifact JSON that describes the artifact. This information is used to when the end user deploying the VM browses artifact repository.

Apart from what is used in the above JSON file, artifact JSON supports parameters as well. For this VS Code artifact, we don’t need parameters. We will see that in a later post. While the other elements in the JSON syntax are important, the one highlighted above (line 14) is what does the magic. It calls the script we saw earlier and then downloads and installs VS Code.

I wouldn’t go through the details of creating and adding VMs to a Azure DevTest Lab service. It is very well documented. But, once you add a VM and attach the VS Code artifact, you should see the VM getting deployed and towards the end, you will see that the artifact gets installed.


This is it. I wanted to explore authoring custom artifacts and found it really simple. If you want to grab the code, head to my Github repository. I have submitted a pull request to the Azure Team repository for DevTest Lab service.  This artifact is now accepted into the official Azure DevTest Lab repository and you should be able to add it from the portal without using a custom respository.

How can we do this whole thing using ARM templates? Let’s keep that for a later post.

Filed under: Azure


Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.