In a previous post I told you the new Azure DevTest Labs service (still in preview) , which allows you to create test and development environments for your team. One of the options within the lab is the possibility to enable your own artifacts (applications and tasks) to be available for machines that users can create. Today I‘m going to talk about how to create this repository on GitHub and how you can use it from the service.
Create a repository on GitHub

A new element will be shown, representing the repository just created, and you can select it in order to open the git terminal or Windows Explorer to start creating the structure. Open Explorer and create a folder called artifacts.

Inside that folder, you’re going to create a directory for each artifact you want to expose. For example, create an artifact that allows you to install Skype. Create a folder called windows-skype within artifacts.

We are going to follow the example of the product team and install the tools using Chocolatey to manage our packages.To do so, we will need two scripts, which I’ve recovered from the Azure/azure-devtestlab repository: startChocolatey.ps1 and ChocolateyPackageInstaller.ps1. The first one receives as argument the packages to install, create a user who execute the script as an administrator and launch the second one which receives the name of the packages. It will install chocolatey and request the packages received as a parameter. Save these two files in the folder windows-skype. Finally, you need a file called Artifactfile.json, which should have the following structure in JSON:
{ "$schema": "https://raw.githubusercontent.com/Azure/azure-devtestlab/master/schemas/2015-01-01/dtlArtifacts.json", "title": "Skype", "description": "Installs Skype using the Chocolatey package manager.", "tags": [ "Windows", "Skype" ], "iconUri": "https://chocolatey.org/content/packageimages/skype.7.15.0.102.png", "targetOsType": "Windows", "runCommand": { "commandToExecute": "powershell.exe -executionpolicy bypass -File startChocolatey.ps1 -PackageList skype" } }
- $schema: sets the file schema.
- title: the name of the artifact that you want to appear on the list.
- description: description of the artifact.
- tags: tags that identify the artifact.
- iconUri: icon to be displayed in the list of elements.
- targetOsType: since it is possible to install both Windows and Linux machines, it is necessary to indicate for which type of machines this artifact is intended.
- runCommand -> commandToExecute: this is the command that will be launched when this artifact in the list is selected. As you can see, it makes a call to the script startChocolatey.ps1 passing the list of packages you want to install.
Finally, you have to upload the changes to your repository. To do this simply go to GitHub desktop, click on the tab Changes and commit to master.

Click on Publish to create the repository on GitHub.

If you access your profile (https://github.com/USERNAME) you will see that your new repository is ready.

Associate your repository with Azure DevTest Labs
If you have not yet created an environment of DevTest Labs, you can follow the steps in the previous post. You will see that there is a section called Artifact Repository. Click on it to set up yours.

- Name: name of the repository of artifacts.
- Git Clone Uri: this is the URL that is used to clone a Git repository, you can find it on the page of your repository.
- Folder Path: the root folder where all artifacts are. In this example I‘ve called artifacts.
- Branch: the branch in git where changes are being made to generate this repository. To simplify the process, this post has been used directly the master branch.
- Personal Access Token: to access a repository from github, you need a token. You can generate one from https://github.com/settings/tokens, click on Generate token and leave the scope by default for this scenario. Copy the generated token and paste it in this section.
Create a virtual machine with you artifact
To check that your artifacts are working correctly, you can create a virtual machine that you associate your new artifact. Select Add Lab VM, click on the Artifacts section and you‘ll see that in addition to the official elements you have a new one that comes from your repository.

If during creation you can see that your artifacts have not been installed correctly or some error occurred during the process,there is a log that you can use to know the final result of the installation. Select the virtual machine and go to Settings > Extensions > customScriptArtifact.

Happy weekend!