Collection of build/release tasks to interact with Azure DevTest Labs.
- Azure Pipelines Tasks - source code for out of the box tasks provided with Azure DevOps.
- Article Add a build or release task.
See the RELEASENOTES.md file for details.
The following are tools used to create these tasks and are recommended.
- The latest version of Visual Studio Code.
- The latest version of Azure CLI.
- Node.js v24 LTS or later.
- Typescript Compiler v2.2.0 or later.
- This should already be part of the dependencies, when configuring the project for the first time.
- If you have problems running it, simply install it globally:
npm install typescript -g
- TFS Cross Platform Command Line Interface
- The
tfx-clican be installed usingnpm, a component ofNode.jsby runningnpm i -g tfx-cli
- The
To configure your local environment, after cloning the repo, do the following:
-
From within VS Code's
Terminalwindow, navigate to./tasks/Node -
Generate file
authfile.jsonto be used for running the tasks locally.If you're asked to authenticate, run command:
az login --use-device-codeEnsure you switch to the desired subscription, if have access to more than one.
To generate the file, run command:
az ad sp create-for-rbac --sdk-auth > authfile.jsonIf you get errors parsing the JSON, ensure the format of the file is UTF-8. You can force it by using the alternate command:
az ad sp create-for-rbac --sdk-auth | out-file -encoding utf8 authfile.json -
Run command to download all dependencies.
npm run init-mods -
Run command to initialize your development environment. The command will clean the
outfolder, copy the necessary files and compile the task code for local running.npm run init-dev
After doing the above steps you can just compile the code by calling tsc in the command line.
To test any changes locally, do the following:
-
For now, open the corresponding
task.tsfile, navigate to the functiontestRun(), pay attention to any references todata. The values are expected to come from a file calledtestdata.jsonthat you can place in the same folder astask.ts.Here's a sample
testdata.jsonfor taskAzureDtlDeleteVm. Replace any values in angle brackets (e.g.<subId>).{ "subscriptionId": "<subId>", "labVmId": "/subscriptions/<subId>/resourcegroups/<rgName>/providers/microsoft.devtestlab/labs/<labName>/virtualmachines/<vmName>" }TODO: Add tests that will supersede the above approach.
-
Compile the code.
tscor, copy structure and compile the code.
npm run build-dev -
Run the task you want to test; for example, to test creating a custom image, run command:
node .\out\tasks\AzureDtlCreateCustomImage\task.js --test
You can also combine commands as follows:
cls; npm run build-dev; node .\out\tasks\AzureDtlCreateCustomImage\task.js --test
To package the extension for publishing, run command:
npm run package
A file similar to ./dist/ms-azuredevtestlabs-dev.dtl-tasks-0.0.0.vsix will be created.