In this article

Create custom artifacts for your DevTest Labs virtual machine

07/11/2018

4 minutes to read

Contributors

In this article

Watch the following video for an overview of the steps described in this article:

Overview

You can use artifacts to deploy and set up your application after you provision a VM. An artifact consists of an artifact definition file and other script files that are stored in a folder in a Git repository. Artifact definition files consist of JSON and expressions that you can use to specify what you want to install on a VM. For example, you can define the name of an artifact, a command to run, and parameters that are available when the command is run. You can refer to other script files within the artifact definition file by name.

Artifact definition file format

The following example shows the sections that make up the basic structure of a definition file:

Type of parameter value. See the following list for the allowed types.

displayName

Yes

Name of the parameter that is displayed to a user in the lab.

description

Yes

Description of the parameter that is displayed in the lab.

Allowed types are:

string (any valid JSON string)

int (any valid JSON integer)

bool (any valid JSON Boolean)

array (any valid JSON array)

Artifact expressions and functions

You can use expressions and functions to construct the artifact install command.
Expressions are enclosed with brackets ([ and ]), and are evaluated when the artifact is installed. Expressions can appear anywhere in a JSON string value. Expressions always return another JSON value. If you need to use a literal string that starts with a bracket ([), you must use two brackets ([[).
Typically, you use expressions with functions to construct a value. Just like in JavaScript, function calls are formatted as functionName(arg1, arg2, arg3).

The following list shows common functions:

parameters(parameterName): Returns a parameter value that is provided when the artifact command is run.

concat(arg1, arg2, arg3,….. ): Combines multiple string values. This function can take a variety of arguments.

The following example shows how to use expressions and functions to construct a value:

Create a custom artifact

Install a JSON editor. You need a JSON editor to work with artifact definition files. We recommend using Visual Studio Code, which is available for Windows, Linux, and OS X.

Get a sample artifactfile.json definition file. Check out the artifacts created by the DevTest Labs team in our GitHub repository. We have created a rich library of artifacts that can help you create your own artifacts. Download an artifact definition file and make changes to it to create your own artifacts.

Make use of IntelliSense. Use IntelliSense to see valid elements that you can use to construct an artifact definition file. You also can see the different options for values of an element. For example, when you edit the targetOsType element, IntelliSense shows you two choices, for Windows or Linux.