About This Page
This page is part of the Azure documentation. It contains code examples and configuration instructions for working with Azure services.
Bias Analysis
Bias Types:
⚠️
powershell_heavy
⚠️
windows_first
⚠️
missing_linux_example
Summary:
The documentation page demonstrates a Windows bias by providing detailed instructions and scripts exclusively using Azure PowerShell, with no equivalent Bash or Linux-native scripting examples. The deployment sections and automation guidance are PowerShell-centric, and there is no mention of Linux command-line tools or cross-platform scripting approaches. While the Azure CLI is briefly mentioned as an alternative for ARM template deployment, no CLI or Bash examples are actually provided, and all code samples and step-by-step automation are in PowerShell.
Recommendations:
- Provide equivalent Azure CLI (az) and Bash script examples for adding artifact repositories, including full scripts and parameter explanations.
- Include Linux/macOS-specific instructions for running scripts and managing authentication, such as using environment variables for tokens.
- When listing deployment options (e.g., ARM template deployment), present Azure CLI and Bash examples before or alongside PowerShell examples, not after.
- Clarify that all automation steps can be performed on Linux/macOS as well as Windows, and provide any necessary prerequisites or differences.
- Add a section or tab for Linux users, mirroring the structure used for PowerShell, to ensure parity and inclusivity.
Create pull request
Flagged Code Snippets
New-AzResourceGroup -Name MyLabResourceGroup1 -Location westus
New-AzResourceGroupDeployment `
-Name MyLabResourceGroup-Deployment1 `
-ResourceGroupName MyLabResourceGroup1 `
-TemplateFile azuredeploy.json `
-TemplateParameterFile azuredeploy.parameters.json
<#
.SYNOPSIS
This script creates a new custom repository and adds it to an existing DevTest Lab.
.PARAMETER LabName
The name of the lab.
.PARAMETER LabResourceGroupName
The name of the resource group that contains the lab.
.PARAMETER ArtifactRepositoryName
Name for the new artifact repository. The script creates a random name for the repository if not specified.
.PARAMETER ArtifactRepositoryDisplayName
Display name for the artifact repository.
This name appears in the list of artifact repositories for a lab.
.PARAMETER RepositoryUri
Uri to the artifact repository.
.PARAMETER RepositoryBranch
Branch that contains the artifact files. Defaults to 'main'.
.PARAMETER FolderPath
Folder that contains the artifact files. Defaults to '/Artifacts'
.PARAMETER PersonalAccessToken
Personal access token for the GitHub or Azure Repos repository.
.PARAMETER SourceType
Whether the artifact repository is a VSOGit (Azure Repos) or GitHub repository.
.EXAMPLE
Set-AzContext -SubscriptionId aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e
.\New-DevTestLabArtifactRepository.ps1 -LabName "mydevtestlab" -LabResourceGroupName "mydtlrg" -ArtifactRepositoryName "MyTeam Repository" -RepositoryUri "https://github.com/<myteam>/<nameofrepo>.git" -PersonalAccessToken "1111...." -SourceType "GitHub"
.NOTES
The script uses the current Azure context. To set the context, use Set-AzContext.
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
$LabName,
[Parameter(Mandatory=$true)]
$LabResourceGroupName,
$ArtifactRepositoryName,
$ArtifactRepositoryDisplayName = 'Team Artifact Repository',
[Parameter(Mandatory=$true)]
$RepositoryUri,
$RepositoryBranch = 'main',
$FolderPath = '/Artifacts',
[Parameter(Mandatory=$true)]
$PersonalAccessToken ,
[Parameter(Mandatory=$true)]
[ValidateSet('VsoGit', 'GitHub')]
$SourceType
)
# Set artifact repository internal name if not specified.
if ($ArtifactRepositoryName -eq $null){
$ArtifactRepositoryName = "PrivateRepo" + (Get-Random -Maximum 999)
}
# Sign in to Azure.
Connect-AzAccount
#Get Lab Resource.
$LabResource = Get-AzResource -ResourceType 'Microsoft.DevTestLab/labs' -ResourceName $LabName -ResourceGroupName $LabResourceGroupName
Write-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 be passed to New-AzResource:$($propertiesObject | Out-String)"
#Add resource to the current subscription.
$resourcetype = 'Microsoft.DevTestLab/labs/artifactSources'
$resourceName = $LabName + '/' + $ArtifactRepositoryName
Write-Verbose "Az ResourceType: $resourcetype"
Write-Verbose "Az ResourceName: $resourceName"
Write-Verbose "Creating artifact repository '$ArtifactRepositoryDisplayName'..."
$result = New-AzResource -Location $LabResource.Location -ResourceGroupName $LabResource.ResourceGroupName -properties $propertiesObject -ResourceType $resourcetype -ResourceName $resourceName -ApiVersion 2016-05-15 -Force
#Alternate implementation:
# Use resourceId rather than resourcetype and resourcename parameters.
# Using resourceId lets you specify the $SubscriptionId rather than using the
# subscription id of 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 source '$ArtifactRepositoryDisplayName'")
}
else {
Write-Error ("Error adding artifact repository source '$ArtifactRepositoryDisplayName'")
}
#Return the newly created resource to use in later scripts.
return $result
#Set artifact repository name, if not set by user
if ($ArtifactRepositoryName -eq $null){
$ArtifactRepositoryName = "PrivateRepo" + (Get-Random -Maximum 999)
}
$resourcetype = 'Microsoft.DevTestLab/labs/artifactSources'
$resourceName = $LabName + '/' + $ArtifactRepositoryName
Set-AzContext -SubscriptionId <Your Azure subscription ID>
.\New-DevTestLabArtifactRepository.ps1 -LabName "mydevtestlab" -LabResourceGroupName "mydtlrg" -ArtifactRepositoryName "myteamrepository" -RepositoryUri "https://github.com/myteam/myteamrepository.git" - "1111...." -SourceType "GitHub"