Add an artifact repository to your lab - Azure DevTest Labs (2023)

  • Article

This article tells you how to get oneartefactrepository to your lab in Azure DevTest Labs. Artifacts are tools or applications that can be installed on virtual machines (VMs). You define artifacts in a JSON file that you load from a GitHub or Azure Repos Git repository.

PublicDevTest Labs GitHub-artefactopslagplaatsprovides many common artifacts for Windows and Linux. The artifacts in this public repository are available in DevTest Labs by default. For information on adding artifacts to VMs, seeAdd artifacts to DevTest Labs VMs.

You can also create custom artifacts that are not available in the public artifact repository. For more information on creating custom artifacts, seeCreate custom artifacts. You can add your custom artifacts to your own artifact repository and add the repository to your lab so that all lab users can use the artifacts.

This article shows you how to add an artifact repository to your lab using the Azure portal, an Azure Resource Management (ARM) template, or Azure PowerShell. You can also use an Azure PowerShell or Azure CLI script to automatically add an artifact repository to a lab.


We recommend using the Azure Az PowerShell module to interact with Azure. To seeInstalleer Azure PowerShellstart. For more information about migrating to the Az PowerShell module, seeMigrate Azure PowerShell from AzureRM to Az.

(Video) Create Custom Artifacts for Azure Devtest Labs


To add an artifact repository to a lab, you need to know the Git HTTPS clone URL and personal access token for the GitHub or Azure repository that contains the artifact files.

Download the clone URL and personal access token for GitHub

  1. From the home page, select the GitHub repository containing your artifactsCode, and belowClone, copy the HTTPS URL.
  2. Select your profile picture in the top right corner of GitHub and then selectInstitutions.
  3. Select on your profile page in the left menuDeveloper settingsand then selectPersonal access tokens.
  4. SelectGenerate a new token.
  5. On theNew personal access tokenpage, belowRemark, enter an optional description for the token. Accept all defaults and then selectGenerate token.
  6. Save the generated token.

Download the clone URL and personal access token for Azure repositories

  1. From the main page of the repository containing your artifacts, selectClone. On theClone repositorypage, copy the clone URL.
  2. Select in the top right corner of the Azure DevOps pageUser settings>Personal access tokens.
  3. On thePersonal access tokenspage, selectNew sign.
  4. Fill in the information for the token and selectReadfor the ranges, and then selectTo create.
  5. On theSuccespage, make sure you copy the token because Azure Repos does not store or display the token again.

Add an artifact repository to a lab in the Azure portal

  1. At the labOverviewpage, selectConfiguration and Policyfrom the left navigation.

  2. On theConfiguration and Policypage, selectRepositoriesbelowExternal Resourcesin the left navigation.

    On theRepositoriespage, thePublic Artifact Repois automatically present and connects to theDevTest Labs public GitHub repository. If this repository is not enabled for your lab, you can enable it by selecting the checkbox next to itPublic Artifact Repoand then selectSwitchin the top menu bar.

  3. Select to add your artifact repository to the labAddin the top menu bar.

    (Video) How To Create Custom Artifacts For Virtual Machines In An Azure DevTest Lab

    Add an artifact repository to your lab - Azure DevTest Labs (1)

  4. In theStorage placeenter the following information:

    • Name: A repository name for use in the lab.
    • Git clone URL: The Git HTTPS clone URL from GitHub or Azure Repos.
    • So(optional): The branch that has your artifact definitions.
    • Personal access token: The GitHub or Azure Repos personal access token.
    • The map pad: The directory for your ARM template definitions, relative to the Git clone URL. Be sure to include the first forward slash in the folder path.
  5. SelectRedden.

    Add an artifact repository to your lab - Azure DevTest Labs (2)

The repository will now appear in theRepositorieslab list.

Add an artifact repository using an ARM template

ARM templates are JSON files that describe Azure resources to be created. For more information about ARM templates, seeUnderstand the structure and syntax of ARM templates.

The following ARM template adds an artifact repository to a lab. The template creates the lab if it doesn't already exist.

(Video) How to get started with Azure DevTest Labs | Azure Tips and Tricks

View the ARM template

The sample template collects the following information in parameters. Some parameters have default values, but the deployment command must specify the lab name, artifact repository URI, repository type, and repository private access token.

  • lab name.
  • Display name for the artifact repository in DevTest Labs. The default value isTeam Repository.
  • URI of the artifact repository, which you copied earlier.
  • Repository branch that contains the artifacts. The default value ismain.
  • Name of the folder containing the artifacts. The default value is:/Artifacts.
  • Repository type. The allowed values ​​areVsoGit, for Azure Repos, orGitHub.
  • Personal access token for the repository, which you copied earlier.
{ "$schema": "", "contentVersion": "", "parameters": { "labName ": { "type": "string" }, "artifactRepositoryDisplayName": { "type": "string", "defaultValue": "Team Repository" }, "artifactRepoUri": { "type": "string" }, " artefactRepoBranch": { "type": "string", "defaultValue": "main" }, "artifactRepoFolder": { "type": "string", "defaultValue": "/Artifacts" }, "artifactRepoType": { " type": "string", "allowedValues": ["VsoGit", "GitHub"] }, "artifactRepoSecurityToken": { "type": "securestring" } }, "variables": { "artifactRepositoryName": "[concat( 'Repo-', uniqueString(subscription().subscriptionId))]" }, "resources": [{ "apiVersion": "2016-05-15", "type": "Microsoft.DevTestLab/labs", "name ": "[parameters('labName')]", "location": "[resourceGroup().location]", "resources": [ { "apiVersion": "2016-05-15", "name": " [variabelen('artifactRepositoryName')]", "type": "artifactSources", "dependsOn": [ "[resourceId('Microsoft.DevTestLab/labs', parameters('labName'))]" ], "properties": { "uri": "[parameters('artifactRepoUri')]", "folderPath": "[parameters('artifactRepoFolder')]", "branchRef": "[parameters('artifactRepoBranch')]", "displayName": "[parameters('artifactRepositoryDisplayName')]", "securityToken": "[parameters('artifactRepoSecurityToken')]", "sourceType": "[parameters('artifactRepoType')]", "status": "Ingeschakeld" } } ] } ]}

Implement the template

There are several ways to deploy ARM templates to create or update Azure resources. For information and instructions, see the following articles:

  • Deploy resources with ARM templates and Azure PowerShell
  • Deploy resources with ARM templates and Azure CLI
  • Deploy resources with ARM templates in the Azure portal
  • Deploy resources with ARM templates and Resource Manager REST API

For this example, deploy the template using Azure PowerShell.


The cmdlets that deploy the template are context-specific, so they use the current tenant and subscription. To change the context, useSet-AzContextbefore deploying the template

  1. Create a resource group usingNew-AzResourceGroup. Skip this step if the resource group you want to use already exists.

    (Video) Learn Azure DevTest Labs Step by Step #devopstutorial #azurecloud #devtestlabs #azuretraining

    New-AzResourceGroup -Name MyLabResourceGroup1 -Locatie westus
  2. Create a deployment to the resource group usingNew-AzResourceGroupDeployment. You can create multiple resource deployments for the same resource group. If you deploy to the same resource group multiple times, make sure each deployment name is unique.

    New-AzResourceGroupDeployment ` -Name MyLabResourceGroup-Deployment1 ` -ResourceGroupName MyLabResourceGroup1 ` -TemplateFile azuredeploy.json ` -TemplateParameterFile azuredeploy.parameters.json

AlreadyNew-AzResourceGroupDeploymentruns successfully, the output shows important information, such as the provisioning state, which it should bepassed, and any output for the template.

Add an artifact repository using Azure PowerShell

The following sample PowerShell script,New-DevTestLabArtifactRepository.ps1, adds an artifact repository to a lab. The full script contains some extensive messages and comments.

<#.SYNOPSISThis script creates a new custom repository and adds it to an existing DevTest Lab..PARAMETER LabNameThe name of the lab..PARAMETER LabResourceGroupNameThe name of the resource group containing the lab..PARAMETER ArtifactRepositoryNameName for the new artifact repository. The script creates a random name for the repository if not specified..PARAMETER ArtifactRepositoryDisplayNameDisplay name for the artifact repository.This name appears in the list of artifact repositories for a lab..PARAMETER RepositoryUriUri to the artifact repository..PARAMETER RepositoryBranchBranch containing the artifact files . Defaults to 'main'..PARAMETER FolderPathFolder which contains the artifact files. Defaults to '/Artifacts'.PARAMETER PersonalAccessTokenPersonal access token for the GitHub or Azure Repos repository..PARAMETER SourceTypeWhether the artifact repository is a VSOGit (Azure Repos) or GitHub repository..EXAMPLESet-AzContext -SubscriptionId 11111111-1111-1111-1111 - 111111111111.\New-DevTestLabArtifactRepository.ps1 -LabName "mydevtestlab" -LabResourceGroupName "mydtlrg" -ArtifactRepositoryName "MyTeam Repository" -RepositoryUri "" -PersonalAccessToken "1111. ..." -SourceType "GitHub".NOTE The script uses the current Azure context. Use Set-AzContext.#>[CmdletBinding()]Param( [Parameter(Mandatory=$true)] $LabName, [Parameter(Mandatory= $true)] $LabResourceGroupName, $ArtifactRepositoryName, $ArtifactRepositoryDisplayName = 'to set context. Team Artifact Repository', [Parameter(Required=$true)] $RepositoryUri, $RepositoryBranch = 'main', $FolderPath = '/ Artifacts', [Parameter(Required=$true)] $PersonalAccessToken, [Parameter(Required=$true)] [ValidateSet('VsoGit', 'GitHub')] $SourceType)# Set the internal name of the artifact repository if not specified.if ($ArtifactRepositoryName -eq $null){ $ArtifactRepositoryName = "PrivateRepo" + (Get-Random - Up to 999)}# Log in to Azure.Connect-AzAccount#Get Lab Resource.$LabResource = Get-AzResource -ResourceType ' Microsoft.DevTestLab/labs' -ResourceName $LabName -ResourceGroupName $LabResourceGroupNameWrite-Verbose "Lab Name: $($LabResource.Name)"Write-Verbose "Lab Resource Group Name: $($LabResource.ResourceGroupName)"Write-Verbose "Lab Resource Location: $($LabResource.Location)"Write-Verbose "Artifact Repository Internal Name: $ArtifactRepositoryName" #Prepare properties object for the call to New-AzResource.$propertiesObject = @{ uri = $RepositoryUri; folderPath = $FolderPath; branchRef = $RepositoryBranch; displayName = $ArtifactRepositoryDisplayName; securityToken = $PersonalAccessToken; sourceType = $SourceType; status = 'Enabled'}Write-Verbose "Properties to pass to New-AzResource:$($propertiesObject | Out-String)"#Add resource to current subscription.$resourcetype = 'Microsoft.DevTestLab/labs/artifactSources '$resourceName = $LabName + '/' + $ArtifactRepositoryNameWrite-Verbose "Az ResourceType: $resourcetype"Write-Verbose "Az ResourceName: $resourceName"Write-Verbose "Create Artifact Repository '$ArtifactRepositoryDisplayName'..."$result = New- AzResource -Location $LabResource.Location -ResourceGroupName $LabResource.ResourceGroupName -properties $propertiesObject -ResourceType $resourcetype -ResourceName $resourceName -ApiVersion 2016-05-15 -Force#Alternative implementation:# Use resourceId instead of resource type parameters and resource name. # Usage ResourceId allows you to specify the $SubscriptionId instead of using the # subscription ID from Get-AzContext.#$resourceId = "/subscriptions/$SubscriptionId/resourceGroups/$($LabResource.ResourceGroupName)/providers /Microsoft.DevTestLab/labs/$LabName /artifactSources/$ArtifactRepositoryName"#$result = New-AzResource -properties $propertiesObject -ResourceId $resourceId -ApiVersion 2016-05-15 -Force# Check the result.if ($result.Properties .ProvisioningState -eq "Succeeded") { Write-Verbose("Successfully added artifact repository resource '$ArtifactRepositoryDisplayName'")}else { Write-Error("Error adding artifact repository resource '$ArtifactRepositoryDisplayName'")} #Return the newly created resource for use in later scripts.return $result


The PowerShell script uses the following parameters:

LabnaamThe name of the lab.
ArtifactRepositoryNameName for the new artifact repository. The script creates a random name for the repository if not specified.
ArtifactRepositoryDisplayNameDisplay name that appears in the lab's list of artifact repositories.
Repository-URIURI of the artifact repository, which you copied earlier.
RepositoryBranchRepository branch that contains the artifacts. The default value ismain.
FolderPathFolder containing the artifacts. The default value is:/Artifacts.
PersonalAccessTokenSecurity token to access the repository, which you copied earlier.
Bron TypeWhether the artifact repository is a VSOGit (Azure Repos) or GitHub repository.

The repository needs an internal name for identification, which is different from the display name in the Azure portal. You don't see the internal name when you use the Azure portal, but you do when you use Azure REST APIs or Azure PowerShell. The script creates a random name if the implementation command does not specify one.

#Set artifact repository name, if not set by userif ($ArtifactRepositoryName -eq $null){ $ArtifactRepositoryName = "PrivateRepo" + (Get-Random -Maximum 999)}

PowerShell commands

The script uses the following PowerShell commands:

Get-AzResourceGet details about the lab, such as its location. You create the artifact repository resource in the same location and under the same resource group as the lab.
New-AzResourceAdds the Azure resource. There is no specific command for adding artifact repositories. This cmdlet has itResourceIdof deSource nameInBrontypepair to know what type of resource you want to create. The current script uses theSource nameInBrontypepair.

A good way to find information about the resource name and resource type is to read theAzure REST API-browserwebsite. DevTest-labsSources of Artifactsshows REST APIs for creating and managing DevTest Labs artifact resources. The current script uses the following resource ID:

(Video) Azure DevTest Labs Walkthrough{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/artifactsources/{name}

The resource type is whatever is listed after thatprovidersin the URI, except for items enclosed in braces. The resource name is anything between the braces. If you use more than one entry for the resource name, separate each entry with a slash:

$resourcetype = 'Microsoft.DevTestLab/labs/artifactSources'$resourceName = $LabName + '/' + $ArtifactRepositoryName

Run the PowerShell script

Run the PowerShell script, replacing your own values ​​with the sample values ​​inLabnaam,LabResourceGroupName,ArtifactRepositoryName,Repository-URI,PersonalAccessToken, InBron Type:

Set-AzContext -SubscriptionId.\New-DevTestLabArtifactRepository.ps1 -LabName "mydevtestlab" -LabResourceGroupName "mydtlrg" -ArtifactRepositoryName "myteamrepository" -RepositoryUri "" - "1111...." -SourceType "GitHub"

Next steps

  • Specify mandatory artifacts for DevTest Labs VMs
  • Diagnose artifact defects in the lab


How do I add an artifact to my Azure VM? ›

Add artifacts to VMs from the Azure portal
  1. On the lab's home page, select Add.
  2. On the Choose a base page, select the type of VM you want.
  3. On the Create lab resource screen, select Add or Remove Artifacts.
  4. On the Add artifacts page, select the arrow next to each artifact you want to add to the VM.
Jan 18, 2023

What is the limit of Azure DevOps artifacts? ›

Azure Artifacts is free for every organization up to 2 GiB of storage. Once you reach the maximum storage limit, you can no longer upload new artifacts and need to delete some of your existing artifacts or set up billing to increase your storage limit.

How do I create a custom image in Azure DevTest labs? ›

In the Azure portal, on your lab's Overview page, select the VM to use for the image from the My virtual machines list. On the VM's Overview page, select Create custom image under Operations in the left navigation. On the Create custom image page, enter a Name and optional Description for the custom image.

Which settings do you need to configure to create a test lab environment using the Azure portal? ›

Create a lab
  • In the Azure portal, search for and select devtest labs.
  • On the DevTest Labs page, select Create. ...
  • On the Basic Settings tab, provide the following information: ...
  • Optionally, select the Auto-shutdown, Networking, or Tags tabs at the top of the page, and customize those settings.
Mar 31, 2022

How do I add an artifact to Azure DevOps? ›

How to Set Up Azure DevOps and Create an Artifact
  1. Set Up Azure DevOps. ...
  2. Adding Your Project to Azure DevOps Repos. ...
  3. Setting the build pipeline. ...
  4. Configuring the build pipeline. ...
  5. Configuring the build pipeline build tasks. ...
  6. Adding the build tasks. ...
  7. Link build parameters. ...
  8. Adding final task.
Jan 5, 2021

How do I upload an artifact to Azure DevOps? ›

artifactName: the name of the artifact that you want to create.
  1. Add the Publish Pipeline Artifact task.
  2. Fill out the following fields: Display name: artifact display name. File or directory path: the path of the file or directory to publish. Artifact name: name of the artifact to publish.
Nov 29, 2022


1. How To Create A New Azure DevTest Lab
(TechSnips by ATA Learning)
2. How To Troubleshoot Azure DevTest Lab Artifact Failures
(TechSnips by ATA Learning)
3. An Overview of Azure DevTest Labs
(Frank Boucher)
4. Lab19 Azure Artifacts
(DevOps in Tamil)
5. Azure DevTest Labs - Part 2: How to use Azure DevTest Labs to create Infrastructure and Services
(Daniel Meixner)
6. Azure DevTest Labs
(Azure Power Lunch)


Top Articles
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated: 06/04/2023

Views: 5554

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.