
Azure Devops Cli
- 12.3k installs
- 37.1k repo stars
- Updated July 28, 2026
- github/awesome-copilot
azure-devops-cli is a skill providing command reference for managing Azure DevOps resources via CLI automation.
About
azure-devops-cli provides comprehensive Azure DevOps CLI command reference for managing repos, pipelines, builds, work items, RBAC, and service connections. It covers authentication, CLI structure, reference commands for six domains (repos, pipelines, boards, artifacts, variables, security), and automation patterns. Developers use it to automate CI/CD workflows and infrastructure setup.
- Azure DevOps resource management via CLI (repos, pipelines, work items, artifacts)
- Commands for projects, pull requests, builds, releases, RBAC, and service endpoints
- Reference files for workflows, automation scripts, and error handling patterns
Azure Devops Cli by the numbers
- 12,255 all-time installs (skills.sh)
- +246 installs in the week ending Jul 28, 2026 (Skillselion tracking)
- Ranked #17 of 1,453 DevOps & CI/CD skills by installs in the Skillselion catalog
- Security screen: HIGH risk (skills.sh audit)
- Data as of Jul 28, 2026 (Skillselion catalog sync)
azure-devops-cli capabilities & compatibility
- Capabilities
- ci cd · automation · infrastructure
- Works with
- azure · azure devops
- Use cases
- ci cd
- IDEs
- vscode
What azure-devops-cli says it does
Manage Azure DevOps resources using the Azure CLI with the Azure DevOps extension
npx skills add https://github.com/github/awesome-copilot --skill azure-devops-cliAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 12.3k |
|---|---|
| repo stars | ★ 37.1k |
| Security audit | 2 / 3 scanners passed |
| Last updated | July 28, 2026 |
| Repository | github/awesome-copilot ↗ |
What it does
azure-devops-cli provides comprehensive Azure DevOps CLI command reference for managing repos, pipelines, builds, work items, RBAC, and service connections. It covers authentication, CLI structure, r
Who is it for?
DevOps engineers and developers automating Azure DevOps setup, CI/CD pipelines, and cross-project workflows
Skip if: On-premises or non-Azure DevOps environments
When should I use this skill?
Automating Azure DevOps workflows, setting up CI/CD pipelines, or managing projects programmatically
What you get
Automated Azure DevOps workflow (pipeline creation, RBAC config, repo management, artifact handling)
- az command recipes
- JMESPath query examples
Files
Azure DevOps CLI
Manage Azure DevOps resources using the Azure CLI with the Azure DevOps extension.
CLI Version: 2.81.0 (current as of 2025)
Prerequisites
# Install Azure CLI
brew install azure-cli # macOS
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # Linux
# Install Azure DevOps extension
az extension add --name azure-devopsAuthentication
# Login with PAT token
az devops login --organization https://dev.azure.com/{org} --token YOUR_PAT_TOKEN
# Set default organization and project (avoids repeating --org/--project)
# Note: Legacy URL https://{org}.visualstudio.com should be replaced with https://dev.azure.com/{org}
az devops configure --defaults organization=https://dev.azure.com/{org} project={project}
# List current configuration
az devops configure --listCLI Structure
az devops # Main DevOps commands
├── admin # Administration (banner)
├── extension # Extension management
├── project # Team projects
├── security # Security operations
│ ├── group # Security groups
│ └── permission # Security permissions
├── service-endpoint # Service connections
├── team # Teams
├── user # Users
├── wiki # Wikis
├── configure # Set defaults
├── invoke # Invoke REST API
├── login # Authenticate
└── logout # Clear credentials
az pipelines # Azure Pipelines
├── agent # Agents
├── build # Builds
├── folder # Pipeline folders
├── pool # Agent pools
├── queue # Agent queues
├── release # Releases
├── runs # Pipeline runs
├── variable # Pipeline variables
└── variable-group # Variable groups
az boards # Azure Boards
├── area # Area paths
├── iteration # Iterations
└── work-item # Work items
az repos # Azure Repos
├── import # Git imports
├── policy # Branch policies
├── pr # Pull requests
└── ref # Git references
az artifacts # Azure Artifacts
└── universal # Universal PackagesReference Files
Read the relevant reference file based on the user's task. Each file contains complete command syntax and examples for its domain.
| File | When to read | Covers |
|---|---|---|
references/repos-and-prs.md | Repos, branches, pull requests, branch policies | Repositories, Import, PRs (create/list/vote/reviewers/policies), Git refs, Branch policies |
references/pipelines-and-builds.md | Pipelines, builds, releases, artifacts | Pipelines CRUD, runs, builds, releases, artifacts download/upload |
references/boards-and-iterations.md | Work items, sprints, area paths | Work items (WIQL/create/update/relations), Area paths, Iterations, Team iterations |
references/variables-and-agents.md | Pipeline variables, agent pools | Pipeline variables, Variable groups, Pipeline folders, Agent pools/queues |
references/org-and-security.md | Projects, teams, users, permissions, wikis | Projects, Extensions, Teams, Users, Security groups/permissions, Service endpoints, Wikis, Admin |
references/advanced-usage.md | Output formatting, JMESPath queries | Output formats, JMESPath queries (basic + advanced), Global args, Common params, Git aliases |
references/workflows-and-patterns.md | Automation scripts, best practices, error handling | Common workflows, Best practices, Error handling, Scripting patterns, Real-world examples |
Advanced Usage: Output, Queries & Parameters
Table of Contents
- Output Formats
- JMESPath Queries
- Advanced JMESPath Queries
- Global Arguments
- Common Parameters
- Git Aliases
- Getting Help
---
Output Formats
All commands support multiple output formats:
# Table format (human-readable)
az pipelines list --output table
# JSON format (default, machine-readable)
az pipelines list --output json
# JSONC (colored JSON)
az pipelines list --output jsonc
# YAML format
az pipelines list --output yaml
# YAMLC (colored YAML)
az pipelines list --output yamlc
# TSV format (tab-separated values)
az pipelines list --output tsv
# None (no output)
az pipelines list --output noneJMESPath Queries
Filter and transform output:
# Filter by name
az pipelines list --query "[?name=='myPipeline']"
# Get specific fields
az pipelines list --query "[].{Name:name, ID:id}"
# Chain queries
az pipelines list --query "[?name.contains('CI')].{Name:name, ID:id}" --output table
# Get first result
az pipelines list --query "[0]"
# Get top N
az pipelines list --query "[0:5]"Advanced JMESPath Queries
Filtering and Sorting
# Filter by multiple conditions
az pipelines list --query "[?name.contains('CI') && enabled==true]"
# Filter by status and result
az pipelines runs list --query "[?status=='completed' && result=='succeeded']"
# Sort by date (descending)
az pipelines runs list --query "sort_by([?status=='completed'], &finishTime | reverse(@))"
# Get top N items after filtering
az pipelines runs list --query "[?result=='succeeded'] | [0:5]"Nested Queries
# Extract nested properties
az pipelines show --id $PIPELINE_ID --query "{Name:name, Repo:repository.{Name:name, Type:type}, Folder:folder}"
# Query build details
az pipelines build show --id $BUILD_ID --query "{ID:id, Number:buildNumber, Status:status, Result:result, Requested:requestedFor.displayName}"Complex Filtering
# Find pipelines with specific YAML path
az pipelines list --query "[?process.type.name=='yaml' && process.yamlFilename=='azure-pipelines.yml']"
# Find PRs from specific reviewer
az repos pr list --query "[?contains(reviewers[?displayName=='John Doe'].displayName, 'John Doe')]"
# Find work items with specific iteration and state
az boards work-item show --id $WI_ID --query "{Title:fields['System.Title'], State:fields['System.State'], Iteration:fields['System.IterationPath']}"Aggregation
# Count items by status
az pipelines runs list --query "groupBy([?status=='completed'], &[result]) | {Succeeded: [?key=='succeeded'][0].count, Failed: [?key=='failed'][0].count}"
# Get unique reviewers
az repos pr list --query "unique_by(reviewers[], &displayName)"
# Sum values
az pipelines runs list --query "[?result=='succeeded'] | [].{Duration:duration} | [0].Duration"Conditional Transformation
# Format dates
az pipelines runs list --query "[].{ID:id, Date:createdDate, Formatted:createdDate | format_datetime(@, 'yyyy-MM-dd HH:mm')}"
# Conditional output
az pipelines list --query "[].{Name:name, Status:(enabled ? 'Enabled' : 'Disabled')}"
# Extract with defaults
az pipelines show --id $PIPELINE_ID --query "{Name:name, Folder:folder || 'Root', Description:description || 'No description'}"Complex Workflows
# Find longest running builds
az pipelines build list --query "sort_by([?result=='succeeded'], &queueTime) | reverse(@) | [0:3].{ID:id, Number:buildNumber, Duration:duration}"
# Get PR statistics per reviewer
az repos pr list --query "groupBy([], &reviewers[].displayName) | [].{Reviewer:@.key, Count:length(@)}"
# Find work items with multiple child items
az boards work-item relation list --id $PARENT_ID --query "[?rel=='System.LinkTypes.Hierarchy-Forward'] | [].{ChildID:url | split('/', @) | [-1]}"Global Arguments
Available on all commands:
| Parameter | Description |
|---|---|
--help / -h | Show command help |
--output / -o | Output format (json, jsonc, none, table, tsv, yaml, yamlc) |
--query | JMESPath query string for filtering output |
--verbose | Increase logging verbosity |
--debug | Show all debug logs |
--only-show-errors | Only show errors, suppress warnings |
--subscription | Name or ID of subscription |
--yes / -y | Skip confirmation prompts |
Common Parameters
| Parameter | Description |
|---|---|
--org / --organization | Azure DevOps organization URL (e.g., https://dev.azure.com/{org}) |
--project / -p | Project name or ID |
--detect | Auto-detect organization from git config |
--yes / -y | Skip confirmation prompts |
--open | Open resource in web browser |
--subscription | Azure subscription (for Azure resources) |
Git Aliases
After enabling git aliases:
# Enable Git aliases
az devops configure --use-git-aliases true
# Use Git commands for DevOps operations
git pr create --target-branch main
git pr list
git pr checkout 123Getting Help
# General help
az devops --help
# Help for specific command group
az pipelines --help
az repos pr --help
# Help for specific command
az repos pr create --help
# Search for examples
az find "az repos pr create"Work Items, Area Paths & Iterations
Table of Contents
---
Work Items (Boards)
Query Work Items
# WIQL query
az boards query \
--wiql "SELECT [System.Id], [System.Title], [System.State] FROM WorkItems WHERE [System.AssignedTo] = @Me AND [System.State] = 'Active'"
# Query with output format
az boards query --wiql "SELECT * FROM WorkItems" --output tableShow Work Item
az boards work-item show --id {work-item-id}
az boards work-item show --id {work-item-id} --openCreate Work Item
# Basic work item
az boards work-item create \
--title "Fix login bug" \
--type Bug \
--assigned-to user@example.com \
--description "Users cannot login with SSO"
# With area and iteration
az boards work-item create \
--title "New feature" \
--type "User Story" \
--area "Project\\Area1" \
--iteration "Project\\Sprint 1"
# With custom fields
az boards work-item create \
--title "Task" \
--type Task \
--fields "Priority=1" "Severity=2"
# With discussion comment
az boards work-item create \
--title "Issue" \
--type Bug \
--discussion "Initial investigation completed"
# Open in browser after creation
az boards work-item create --title "Bug" --type Bug --openUpdate Work Item
# Update state, title, and assignee
az boards work-item update \
--id {work-item-id} \
--state "Active" \
--title "Updated title" \
--assigned-to user@example.com
# Move to different area
az boards work-item update \
--id {work-item-id} \
--area "{ProjectName}\\{Team}\\{Area}"
# Change iteration
az boards work-item update \
--id {work-item-id} \
--iteration "{ProjectName}\\Sprint 5"
# Add comment/discussion
az boards work-item update \
--id {work-item-id} \
--discussion "Work in progress"
# Update with custom fields
az boards work-item update \
--id {work-item-id} \
--fields "Priority=1" "StoryPoints=5"Delete Work Item
# Soft delete (can be restored)
az boards work-item delete --id {work-item-id} --yes
# Permanent delete
az boards work-item delete --id {work-item-id} --destroy --yesWork Item Relations
# List relations
az boards work-item relation list --id {work-item-id}
# List supported relation types
az boards work-item relation list-type
# Add relation
az boards work-item relation add --id {work-item-id} --relation-type parent --target-id {parent-id}
# Remove relation
az boards work-item relation remove --id {work-item-id} --relation-id {relation-id}Area Paths
List Areas for Project
az boards area project list --project {project}
az boards area project show --path "Project\\Area1" --project {project}Create Area
az boards area project create --path "Project\\NewArea" --project {project}Update Area
az boards area project update \
--path "Project\\OldArea" \
--new-path "Project\\UpdatedArea" \
--project {project}Delete Area
az boards area project delete --path "Project\\AreaToDelete" --project {project} --yesArea Team Management
# List areas for team
az boards area team list --team {team-name} --project {project}
# Add area to team
az boards area team add \
--team {team-name} \
--path "Project\\NewArea" \
--project {project}
# Remove area from team
az boards area team remove \
--team {team-name} \
--path "Project\\AreaToRemove" \
--project {project}
# Update team area
az boards area team update \
--team {team-name} \
--path "Project\\Area" \
--project {project} \
--include-sub-areas trueIterations
List Iterations for Project
az boards iteration project list --project {project}
az boards iteration project show --path "Project\\Sprint 1" --project {project}Create Iteration
az boards iteration project create --path "Project\\Sprint 1" --project {project}Update Iteration
az boards iteration project update \
--path "Project\\OldSprint" \
--new-path "Project\\NewSprint" \
--project {project}Delete Iteration
az boards iteration project delete --path "Project\\OldSprint" --project {project} --yesTeam Iterations
# List iterations for team
az boards iteration team list --team {team-name} --project {project}
# Add iteration to team
az boards iteration team add \
--team {team-name} \
--path "Project\\Sprint 1" \
--project {project}
# Remove iteration from team
az boards iteration team remove \
--team {team-name} \
--path "Project\\Sprint 1" \
--project {project}
# List work items in iteration
az boards iteration team list-work-items \
--team {team-name} \
--path "Project\\Sprint 1" \
--project {project}Default & Backlog Iterations
# Set default iteration for team
az boards iteration team set-default-iteration \
--team {team-name} \
--path "Project\\Sprint 1" \
--project {project}
# Show default iteration
az boards iteration team show-default-iteration \
--team {team-name} \
--project {project}
# Set backlog iteration for team
az boards iteration team set-backlog-iteration \
--team {team-name} \
--path "Project\\Sprint 1" \
--project {project}
# Show backlog iteration
az boards iteration team show-backlog-iteration \
--team {team-name} \
--project {project}
# Show current iteration
az boards iteration team show --team {team-name} --project {project} --timeframe currentOrganization, Security & Administration
Table of Contents
- Projects
- Extension Management
- Service Endpoints
- Teams
- Users
- Security Groups
- Security Permissions
- Wikis
- Administration
- DevOps Extensions
---
Projects
List Projects
az devops project list --organization https://dev.azure.com/{org}
az devops project list --top 10 --output tableCreate Project
az devops project create \
--name myNewProject \
--organization https://dev.azure.com/{org} \
--description "My new DevOps project" \
--source-control git \
--visibility privateShow Project Details
az devops project show --project {project-name} --org https://dev.azure.com/{org}Delete Project
az devops project delete --id {project-id} --org https://dev.azure.com/{org} --yesExtension Management
List Extensions
# List available extensions
az extension list-available --output table
# List installed extensions
az extension list --output tableManage Azure DevOps Extension
# Install Azure DevOps extension
az extension add --name azure-devops
# Update Azure DevOps extension
az extension update --name azure-devops
# Remove extension
az extension remove --name azure-devops
# Install from local path
az extension add --source ~/extensions/azure-devops.whlService Endpoints
List Service Endpoints
az devops service-endpoint list --project {project}
az devops service-endpoint list --project {project} --output tableShow Service Endpoint
az devops service-endpoint show --id {endpoint-id} --project {project}Create Service Endpoint
# Using configuration file
az devops service-endpoint create --service-endpoint-configuration endpoint.json --project {project}Delete Service Endpoint
az devops service-endpoint delete --id {endpoint-id} --project {project} --yesTeams
List Teams
az devops team list --project {project}Show Team
az devops team show --team {team-name} --project {project}Create Team
az devops team create \
--name {team-name} \
--description "Team description" \
--project {project}Update Team
az devops team update \
--team {team-name} \
--project {project} \
--name "{new-team-name}" \
--description "Updated description"Delete Team
az devops team delete --team {team-name} --project {project} --yesShow Team Members
az devops team list-member --team {team-name} --project {project}Users
List Users
az devops user list --org https://dev.azure.com/{org}
az devops user list --top 10 --output tableShow User
az devops user show --user {user-id-or-email} --org https://dev.azure.com/{org}Add User
az devops user add \
--email user@example.com \
--license-type express \
--org https://dev.azure.com/{org}Update User
az devops user update \
--user {user-id-or-email} \
--license-type advanced \
--org https://dev.azure.com/{org}Remove User
az devops user remove --user {user-id-or-email} --org https://dev.azure.com/{org} --yesSecurity Groups
List Groups
# List all groups in project
az devops security group list --project {project}
# List all groups in organization
az devops security group list --scope organization
# List with filtering
az devops security group list --project {project} --subject-types vstsgroupShow Group Details
az devops security group show --group-id {group-id}Create Group
az devops security group create \
--name {group-name} \
--description "Group description" \
--project {project}Update Group
az devops security group update \
--group-id {group-id} \
--name "{new-group-name}" \
--description "Updated description"Delete Group
az devops security group delete --group-id {group-id} --yesGroup Memberships
# List memberships
az devops security group membership list --id {group-id}
# Add member
az devops security group membership add \
--group-id {group-id} \
--member-id {member-id}
# Remove member
az devops security group membership remove \
--group-id {group-id} \
--member-id {member-id} --yesSecurity Permissions
List Namespaces
az devops security permission namespace listShow Namespace Details
# Show permissions available in a namespace
az devops security permission namespace show --namespace "GitRepositories"List Permissions
# List permissions for user/group and namespace
az devops security permission list \
--id {user-or-group-id} \
--namespace "GitRepositories" \
--project {project}
# List for specific token (repository)
az devops security permission list \
--id {user-or-group-id} \
--namespace "GitRepositories" \
--project {project} \
--token "repoV2/{project}/{repository-id}"Show Permissions
az devops security permission show \
--id {user-or-group-id} \
--namespace "GitRepositories" \
--project {project} \
--token "repoV2/{project}/{repository-id}"Update Permissions
# Grant permission
az devops security permission update \
--id {user-or-group-id} \
--namespace "GitRepositories" \
--project {project} \
--token "repoV2/{project}/{repository-id}" \
--permission-mask "Pull,Contribute"
# Deny permission
az devops security permission update \
--id {user-or-group-id} \
--namespace "GitRepositories" \
--project {project} \
--token "repoV2/{project}/{repository-id}" \
--permission-mask 0Reset Permissions
# Reset specific permission bits
az devops security permission reset \
--id {user-or-group-id} \
--namespace "GitRepositories" \
--project {project} \
--token "repoV2/{project}/{repository-id}" \
--permission-mask "Pull,Contribute"
# Reset all permissions
az devops security permission reset-all \
--id {user-or-group-id} \
--namespace "GitRepositories" \
--project {project} \
--token "repoV2/{project}/{repository-id}" --yesWikis
List Wikis
# List all wikis in project
az devops wiki list --project {project}
# List all wikis in organization
az devops wiki listShow Wiki
az devops wiki show --wiki {wiki-name} --project {project}
az devops wiki show --wiki {wiki-name} --project {project} --openCreate Wiki
# Create project wiki
az devops wiki create \
--name {wiki-name} \
--project {project} \
--type projectWiki
# Create code wiki from repository
az devops wiki create \
--name {wiki-name} \
--project {project} \
--type codeWiki \
--repository {repo-name} \
--mapped-path /wikiDelete Wiki
az devops wiki delete --wiki {wiki-id} --project {project} --yesWiki Pages
# List pages
az devops wiki page list --wiki {wiki-name} --project {project}
# Show page
az devops wiki page show \
--wiki {wiki-name} \
--path "/page-name" \
--project {project}
# Create page
az devops wiki page create \
--wiki {wiki-name} \
--path "/new-page" \
--content "# New Page\n\nPage content here..." \
--project {project}
# Update page
az devops wiki page update \
--wiki {wiki-name} \
--path "/existing-page" \
--content "# Updated Page\n\nNew content..." \
--project {project}
# Delete page
az devops wiki page delete \
--wiki {wiki-name} \
--path "/old-page" \
--project {project} --yesAdministration
Banner Management
# List banners
az devops admin banner list
# Show banner details
az devops admin banner show --id {banner-id}
# Add new banner
az devops admin banner add \
--message "System maintenance scheduled" \
--level info # info, warning, error
# Update banner
az devops admin banner update \
--id {banner-id} \
--message "Updated message" \
--level warning \
--expiration-date "2025-12-31T23:59:59Z"
# Remove banner
az devops admin banner remove --id {banner-id}DevOps Extensions
Manage extensions installed in an Azure DevOps organization (different from CLI extensions).
# List installed extensions
az devops extension list --org https://dev.azure.com/{org}
# Search marketplace extensions
az devops extension search --search-query "docker"
# Show extension details
az devops extension show --ext-id {extension-id} --org https://dev.azure.com/{org}
# Install extension
az devops extension install \
--ext-id {extension-id} \
--org https://dev.azure.com/{org} \
--publisher {publisher-id}
# Enable extension
az devops extension enable \
--ext-id {extension-id} \
--org https://dev.azure.com/{org}
# Disable extension
az devops extension disable \
--ext-id {extension-id} \
--org https://dev.azure.com/{org}
# Uninstall extension
az devops extension uninstall \
--ext-id {extension-id} \
--org https://dev.azure.com/{org} --yesPipelines, Builds & Releases
Table of Contents
- Pipelines
- Pipeline Runs
- Builds
- Build Definitions
- Releases
- Release Definitions
- Universal Packages (Artifacts)
---
Pipelines
List Pipelines
az pipelines list --output table
az pipelines list --query "[?name=='myPipeline']"
az pipelines list --folder-path 'folder/subfolder'Create Pipeline
# From local repository context (auto-detects settings)
az pipelines create --name 'ContosoBuild' --description 'Pipeline for contoso project'
# With specific branch and YAML path
az pipelines create \
--name {pipeline-name} \
--repository {repo} \
--branch main \
--yaml-path azure-pipelines.yml \
--description "My CI/CD pipeline"
# For GitHub repository
az pipelines create \
--name 'GitHubPipeline' \
--repository https://github.com/Org/Repo \
--branch main \
--repository-type github
# Skip first run
az pipelines create --name 'MyPipeline' --skip-run trueShow Pipeline
az pipelines show --id {pipeline-id}
az pipelines show --name {pipeline-name}Update Pipeline
az pipelines update --id {pipeline-id} --name "New name" --description "Updated description"Delete Pipeline
az pipelines delete --id {pipeline-id} --yesRun Pipeline
# Run by name
az pipelines run --name {pipeline-name} --branch main
# Run by ID
az pipelines run --id {pipeline-id} --branch refs/heads/main
# With parameters
az pipelines run --name {pipeline-name} --parameters version=1.0.0 environment=prod
# With variables
az pipelines run --name {pipeline-name} --variables buildId=123 configuration=release
# Open results in browser
az pipelines run --name {pipeline-name} --openPipeline Runs
List Runs
az pipelines runs list --pipeline {pipeline-id}
az pipelines runs list --name {pipeline-name} --top 10
az pipelines runs list --branch main --status completedShow Run Details
az pipelines runs show --run-id {run-id}
az pipelines runs show --run-id {run-id} --openPipeline Artifacts
# List artifacts for a run
az pipelines runs artifact list --run-id {run-id}
# Download artifact
az pipelines runs artifact download \
--artifact-name '{artifact-name}' \
--path {local-path} \
--run-id {run-id}
# Upload artifact
az pipelines runs artifact upload \
--artifact-name '{artifact-name}' \
--path {local-path} \
--run-id {run-id}Pipeline Run Tags
# Add tag to run
az pipelines runs tag add --run-id {run-id} --tags production v1.0
# List run tags
az pipelines runs tag list --run-id {run-id} --output tableBuilds
List Builds
az pipelines build list
az pipelines build list --definition {build-definition-id}
az pipelines build list --status completed --result succeededQueue Build
az pipelines build queue --definition {build-definition-id} --branch main
az pipelines build queue --definition {build-definition-id} --parameters version=1.0.0Show Build Details
az pipelines build show --id {build-id}Cancel Build
az pipelines build cancel --id {build-id}Build Tags
# Add tag to build
az pipelines build tag add --build-id {build-id} --tags prod release
# Delete tag from build
az pipelines build tag delete --build-id {build-id} --tag prodBuild Definitions
List Build Definitions
az pipelines build definition list
az pipelines build definition list --name {definition-name}Show Build Definition
az pipelines build definition show --id {definition-id}Releases
List Releases
az pipelines release list
az pipelines release list --definition {release-definition-id}Create Release
az pipelines release create --definition {release-definition-id}
az pipelines release create --definition {release-definition-id} --description "Release v1.0"Show Release
az pipelines release show --id {release-id}Release Definitions
List Release Definitions
az pipelines release definition listShow Release Definition
az pipelines release definition show --id {definition-id}Universal Packages (Artifacts)
Publish Package
az artifacts universal publish \
--feed {feed-name} \
--name {package-name} \
--version {version} \
--path {package-path} \
--project {project}Download Package
az artifacts universal download \
--feed {feed-name} \
--name {package-name} \
--version {version} \
--path {download-path} \
--project {project}Repositories & Pull Requests
Table of Contents
---
Repositories
List Repositories
az repos list --org https://dev.azure.com/{org} --project {project}
az repos list --output tableShow Repository Details
az repos show --repository {repo-name} --project {project}Create Repository
az repos create --name {repo-name} --project {project}Delete Repository
az repos delete --id {repo-id} --project {project} --yesUpdate Repository
az repos update --id {repo-id} --name {new-name} --project {project}Repository Import
Import Git Repository
# Import from public Git repository
az repos import create \
--git-source-url https://github.com/user/repo \
--repository {repo-name}
# Import with authentication
az repos import create \
--git-source-url https://github.com/user/private-repo \
--repository {repo-name} \
--user {username} \
--password {password-or-pat}Pull Requests
Create Pull Request
# Basic PR creation
az repos pr create \
--repository {repo} \
--source-branch {source-branch} \
--target-branch {target-branch} \
--title "PR Title" \
--description "PR description" \
--open
# PR with work items
az repos pr create \
--repository {repo} \
--source-branch {source-branch} \
--work-items 63 64
# Draft PR with reviewers
az repos pr create \
--repository {repo} \
--source-branch feature/new-feature \
--target-branch main \
--title "Feature: New functionality" \
--draft true \
--reviewers user1@example.com user2@example.com \
--required-reviewers lead@example.com \
--labels "enhancement" "backlog"List Pull Requests
# All PRs
az repos pr list --repository {repo}
# Filter by status
az repos pr list --repository {repo} --status active
# Filter by creator
az repos pr list --repository {repo} --creator {email}
# Output as table
az repos pr list --repository {repo} --output tableShow PR Details
az repos pr show --id {pr-id}
az repos pr show --id {pr-id} --open # Open in browserUpdate PR (Complete/Abandon/Draft)
# Complete PR
az repos pr update --id {pr-id} --status completed
# Abandon PR
az repos pr update --id {pr-id} --status abandoned
# Set to draft
az repos pr update --id {pr-id} --draft true
# Publish draft PR
az repos pr update --id {pr-id} --draft false
# Auto-complete when policies pass
az repos pr update --id {pr-id} --auto-complete true
# Set title and description
az repos pr update --id {pr-id} --title "New title" --description "New description"Checkout PR Locally
# Checkout PR branch
az repos pr checkout --id {pr-id}
# Checkout with specific remote
az repos pr checkout --id {pr-id} --remote-name upstreamVote on PR
az repos pr set-vote --id {pr-id} --vote approve
az repos pr set-vote --id {pr-id} --vote approve-with-suggestions
az repos pr set-vote --id {pr-id} --vote reject
az repos pr set-vote --id {pr-id} --vote wait-for-author
az repos pr set-vote --id {pr-id} --vote resetPR Reviewers
# Add reviewers
az repos pr reviewer add --id {pr-id} --reviewers user1@example.com user2@example.com
# List reviewers
az repos pr reviewer list --id {pr-id}
# Remove reviewers
az repos pr reviewer remove --id {pr-id} --reviewers user1@example.comPR Work Items
# Add work items to PR
az repos pr work-item add --id {pr-id} --work-items {id1} {id2}
# List PR work items
az repos pr work-item list --id {pr-id}
# Remove work items from PR
az repos pr work-item remove --id {pr-id} --work-items {id1}PR Policies
# List policies for a PR
az repos pr policy list --id {pr-id}
# Queue policy evaluation for a PR
az repos pr policy queue --id {pr-id} --evaluation-id {evaluation-id}Git References
List References (Branches)
az repos ref list --repository {repo}
az repos ref list --repository {repo} --query "[?name=='refs/heads/main']"Create Reference (Branch)
az repos ref create --name refs/heads/new-branch --object-type commit --object {commit-sha}Delete Reference (Branch)
az repos ref delete --name refs/heads/old-branch --repository {repo} --project {project}Lock/Unlock Branch
az repos ref lock --name refs/heads/main --repository {repo} --project {project}
az repos ref unlock --name refs/heads/main --repository {repo} --project {project}Repository Policies
List All Policies
az repos policy list --repository {repo-id} --branch mainCreate/Update/Delete Policy
# Create from config file
az repos policy create --config policy.json
# Update
az repos policy update --id {policy-id} --config updated-policy.json
# Delete
az repos policy delete --id {policy-id} --yesApprover Count Policy
az repos policy approver-count create \
--blocking true \
--enabled true \
--branch main \
--repository-id {repo-id} \
--minimum-approver-count 2 \
--creator-vote-counts trueBuild Policy
az repos policy build create \
--blocking true \
--enabled true \
--branch main \
--repository-id {repo-id} \
--build-definition-id {definition-id} \
--queue-on-source-update-only true \
--valid-duration 720Work Item Linking Policy
az repos policy work-item-linking create \
--blocking true \
--branch main \
--enabled true \
--repository-id {repo-id}Required Reviewer Policy
az repos policy required-reviewer create \
--blocking true \
--enabled true \
--branch main \
--repository-id {repo-id} \
--required-reviewers user@example.comMerge Strategy Policy
az repos policy merge-strategy create \
--blocking true \
--enabled true \
--branch main \
--repository-id {repo-id} \
--allow-squash true \
--allow-rebase true \
--allow-no-fast-forward trueCase Enforcement Policy
az repos policy case-enforcement create \
--blocking true \
--enabled true \
--branch main \
--repository-id {repo-id}Comment Required Policy
az repos policy comment-required create \
--blocking true \
--enabled true \
--branch main \
--repository-id {repo-id}File Size Policy
az repos policy file-size create \
--blocking true \
--enabled true \
--branch main \
--repository-id {repo-id} \
--maximum-file-size 10485760 # 10MB in bytesPipeline Variables, Variable Groups & Agents
Table of Contents
---
Pipeline Variables
List Variables
az pipelines variable list --pipeline-id {pipeline-id}Create Variable
# Non-secret variable
az pipelines variable create \
--name {var-name} \
--value {var-value} \
--pipeline-id {pipeline-id}
# Secret variable
az pipelines variable create \
--name {var-name} \
--secret true \
--pipeline-id {pipeline-id}
# Secret with prompt
az pipelines variable create \
--name {var-name} \
--secret true \
--prompt true \
--pipeline-id {pipeline-id}Update Variable
az pipelines variable update \
--name {var-name} \
--value {new-value} \
--pipeline-id {pipeline-id}
# Update secret variable
az pipelines variable update \
--name {var-name} \
--secret true \
--value "{new-secret-value}" \
--pipeline-id {pipeline-id}Delete Variable
az pipelines variable delete --name {var-name} --pipeline-id {pipeline-id} --yesVariable Groups
List Variable Groups
az pipelines variable-group list
az pipelines variable-group list --output tableShow Variable Group
az pipelines variable-group show --id {group-id}Create Variable Group
az pipelines variable-group create \
--name {group-name} \
--variables key1=value1 key2=value2 \
--authorize trueUpdate Variable Group
az pipelines variable-group update \
--id {group-id} \
--name {new-name} \
--description "Updated description"Delete Variable Group
az pipelines variable-group delete --id {group-id} --yesVariable Group Variables
# List variables
az pipelines variable-group variable list --group-id {group-id}
# Create non-secret variable
az pipelines variable-group variable create \
--group-id {group-id} \
--name {var-name} \
--value {var-value}
# Create secret variable (will prompt for value if not provided)
az pipelines variable-group variable create \
--group-id {group-id} \
--name {var-name} \
--secret true
# Create secret with environment variable
export AZURE_DEVOPS_EXT_PIPELINE_VAR_MySecret=secretvalue
az pipelines variable-group variable create \
--group-id {group-id} \
--name MySecret \
--secret true
# Update variable
az pipelines variable-group variable update \
--group-id {group-id} \
--name {var-name} \
--value {new-value} \
--secret false
# Delete variable
az pipelines variable-group variable delete \
--group-id {group-id} \
--name {var-name}Pipeline Folders
List Folders
az pipelines folder listCreate Folder
az pipelines folder create --path 'folder/subfolder' --description "My folder"Delete Folder
az pipelines folder delete --path 'folder/subfolder'Update Folder
az pipelines folder update --path 'old-folder' --new-path 'new-folder'Agent Pools
List Agent Pools
az pipelines pool list
az pipelines pool list --pool-type automation
az pipelines pool list --pool-type deploymentShow Agent Pool
az pipelines pool show --pool-id {pool-id}Agent Queues
List Agent Queues
az pipelines queue list
az pipelines queue list --pool-name {pool-name}Show Agent Queue
az pipelines queue show --id {queue-id}Agents
List Agents in Pool
az pipelines agent list --pool-id {pool-id}Show Agent Details
az pipelines agent show --agent-id {agent-id} --pool-id {pool-id}Workflows, Best Practices & Scripting Patterns
Table of Contents
- Common Workflows
- Best Practices
- Error Handling & Retry Patterns
- Scripting Patterns for Idempotent Operations
- Real-World Workflows
---
Common Workflows
Create PR from current branch
CURRENT_BRANCH=$(git branch --show-current)
az repos pr create \
--source-branch $CURRENT_BRANCH \
--target-branch main \
--title "Feature: $(git log -1 --pretty=%B)" \
--openCreate work item on pipeline failure
az boards work-item create \
--title "Build $BUILD_BUILDNUMBER failed" \
--type bug \
--org $SYSTEM_TEAMFOUNDATIONCOLLECTIONURI \
--project $SYSTEM_TEAMPROJECTDownload latest pipeline artifact
RUN_ID=$(az pipelines runs list --pipeline {pipeline-id} --top 1 --query "[0].id" -o tsv)
az pipelines runs artifact download \
--artifact-name 'webapp' \
--path ./output \
--run-id $RUN_IDApprove and complete PR
# Vote approve
az repos pr set-vote --id {pr-id} --vote approve
# Complete PR
az repos pr update --id {pr-id} --status completedCreate pipeline from local repo
# From local git repository (auto-detects repo, branch, etc.)
az pipelines create --name 'CI-Pipeline' --description 'Continuous Integration'Bulk update work items
# Query items and update in loop
for id in $(az boards query --wiql "SELECT ID FROM WorkItems WHERE State='New'" -o tsv); do
az boards work-item update --id $id --state "Active"
doneBest Practices
Authentication and Security
# Use PAT from environment variable (most secure)
export AZURE_DEVOPS_EXT_PAT=$MY_PAT
az devops login --organization $ORG_URL
# Pipe PAT securely (avoids shell history)
echo $MY_PAT | az devops login --organization $ORG_URL
# Set defaults to avoid repetition
az devops configure --defaults organization=$ORG_URL project=$PROJECT
# Clear credentials after use
az devops logout --organization $ORG_URLIdempotent Operations
# Always use --detect for auto-detection
az devops configure --defaults organization=$ORG_URL project=$PROJECT
# Check existence before creation
if ! az pipelines show --id $PIPELINE_ID 2>/dev/null; then
az pipelines create --name "$PIPELINE_NAME" --yaml-path azure-pipelines.yml
fi
# Use --output tsv for shell parsing
PIPELINE_ID=$(az pipelines list --query "[?name=='MyPipeline'].id" --output tsv)
# Use --output json for programmatic access
BUILD_STATUS=$(az pipelines build show --id $BUILD_ID --query "status" --output json)Script-Safe Output
# Suppress warnings and errors
az pipelines list --only-show-errors
# No output (useful for commands that only need to execute)
az pipelines run --name "$PIPELINE_NAME" --output none
# TSV format for shell scripts (clean, no formatting)
az repos pr list --output tsv --query "[].{ID:pullRequestId,Title:title}"
# JSON with specific fields
az pipelines list --output json --query "[].{Name:name, ID:id, URL:url}"Pipeline Orchestration
# Run pipeline and wait for completion
RUN_ID=$(az pipelines run --name "$PIPELINE_NAME" --query "id" -o tsv)
while true; do
STATUS=$(az pipelines runs show --run-id $RUN_ID --query "status" -o tsv)
if [[ "$STATUS" != "inProgress" && "$STATUS" != "notStarted" ]]; then
break
fi
sleep 10
done
# Check result
RESULT=$(az pipelines runs show --run-id $RUN_ID --query "result" -o tsv)
if [[ "$RESULT" == "succeeded" ]]; then
echo "Pipeline succeeded"
else
echo "Pipeline failed with result: $RESULT"
exit 1
fiVariable Group Management
# Create variable group idempotently
VG_NAME="production-variables"
VG_ID=$(az pipelines variable-group list --query "[?name=='$VG_NAME'].id" -o tsv)
if [[ -z "$VG_ID" ]]; then
VG_ID=$(az pipelines variable-group create \
--name "$VG_NAME" \
--variables API_URL=$API_URL API_KEY=$API_KEY \
--authorize true \
--query "id" -o tsv)
echo "Created variable group with ID: $VG_ID"
else
echo "Variable group already exists with ID: $VG_ID"
fiService Connection Automation
# Create service connection using configuration file
cat > service-connection.json <<'EOF'
{
"data": {
"subscriptionId": "$SUBSCRIPTION_ID",
"subscriptionName": "My Subscription",
"creationMode": "Manual",
"serviceEndpointId": "$SERVICE_ENDPOINT_ID"
},
"url": "https://management.azure.com/",
"authorization": {
"parameters": {
"tenantid": "$TENANT_ID",
"serviceprincipalid": "$SP_ID",
"authenticationType": "spnKey",
"serviceprincipalkey": "$SP_KEY"
},
"scheme": "ServicePrincipal"
},
"type": "azurerm",
"isShared": false,
"isReady": true
}
EOF
az devops service-endpoint create \
--service-endpoint-configuration service-connection.json \
--project "$PROJECT"Pull Request Automation
# Create PR with work items and reviewers
PR_ID=$(az repos pr create \
--repository "$REPO_NAME" \
--source-branch "$FEATURE_BRANCH" \
--target-branch main \
--title "Feature: $(git log -1 --pretty=%B)" \
--description "$(git log -1 --pretty=%B)" \
--work-items $WORK_ITEM_1 $WORK_ITEM_2 \
--reviewers "$REVIEWER_1" "$REVIEWER_2" \
--required-reviewers "$LEAD_EMAIL" \
--labels "enhancement" "backlog" \
--open \
--query "pullRequestId" -o tsv)
# Set auto-complete when policies pass
az repos pr update --id $PR_ID --auto-complete trueError Handling & Retry Patterns
Retry Logic for Transient Failures
# Retry function for network operations
retry_command() {
local max_attempts=3
local attempt=1
local delay=5
while [[ $attempt -le $max_attempts ]]; do
if "$@"; then
return 0
fi
echo "Attempt $attempt failed. Retrying in ${delay}s..."
sleep $delay
((attempt++))
delay=$((delay * 2))
done
echo "All $max_attempts attempts failed"
return 1
}
# Usage
retry_command az pipelines run --name "$PIPELINE_NAME"Check and Handle Errors
# Check if pipeline exists before operations
PIPELINE_ID=$(az pipelines list --query "[?name=='$PIPELINE_NAME'].id" -o tsv)
if [[ -z "$PIPELINE_ID" ]]; then
echo "Pipeline not found. Creating..."
az pipelines create --name "$PIPELINE_NAME" --yaml-path azure-pipelines.yml
else
echo "Pipeline exists with ID: $PIPELINE_ID"
fiValidate Inputs
# Validate required parameters
if [[ -z "$PROJECT" || -z "$REPO" ]]; then
echo "Error: PROJECT and REPO must be set"
exit 1
fi
# Check if branch exists
if ! az repos ref list --repository "$REPO" --query "[?name=='refs/heads/$BRANCH']" -o tsv | grep -q .; then
echo "Error: Branch $BRANCH does not exist"
exit 1
fiHandle Permission Errors
# Try operation, handle permission errors
if az devops security permission update \
--id "$USER_ID" \
--namespace "GitRepositories" \
--project "$PROJECT" \
--token "repoV2/$PROJECT/$REPO_ID" \
--allow-bit 2 \
--deny-bit 0 2>&1 | grep -q "unauthorized"; then
echo "Error: Insufficient permissions to update repository permissions"
exit 1
fiPipeline Failure Notification
# Run pipeline and check result
RUN_ID=$(az pipelines run --name "$PIPELINE_NAME" --query "id" -o tsv)
# Wait for completion
while true; do
STATUS=$(az pipelines runs show --run-id $RUN_ID --query "status" -o tsv)
if [[ "$STATUS" != "inProgress" && "$STATUS" != "notStarted" ]]; then
break
fi
sleep 10
done
# Check result and create work item on failure
RESULT=$(az pipelines runs show --run-id $RUN_ID --query "result" -o tsv)
if [[ "$RESULT" != "succeeded" ]]; then
BUILD_NUMBER=$(az pipelines runs show --run-id $RUN_ID --query "buildNumber" -o tsv)
az boards work-item create \
--title "Build $BUILD_NUMBER failed" \
--type Bug \
--description "Pipeline run $RUN_ID failed with result: $RESULT\n\nURL: $ORG_URL/$PROJECT/_build/results?buildId=$RUN_ID"
fiGraceful Degradation
# Try to download artifact, fallback to alternative source
if ! az pipelines runs artifact download \
--artifact-name 'webapp' \
--path ./output \
--run-id $RUN_ID 2>/dev/null; then
echo "Warning: Failed to download from pipeline run. Falling back to backup source..."
# Alternative download method
curl -L "$BACKUP_URL" -o ./output/backup.zip
fiScripting Patterns for Idempotent Operations
Create or Update Pattern
# Ensure pipeline exists, update if different
ensure_pipeline() {
local name=$1
local yaml_path=$2
PIPELINE=$(az pipelines list --query "[?name=='$name']" -o json)
if [[ -z "$PIPELINE" ]]; then
echo "Creating pipeline: $name"
az pipelines create --name "$name" --yaml-path "$yaml_path"
else
echo "Pipeline exists: $name"
fi
}Ensure Variable Group
# Create variable group with idempotent updates
ensure_variable_group() {
local vg_name=$1
shift
local variables=("$@")
VG_ID=$(az pipelines variable-group list --query "[?name=='$vg_name'].id" -o tsv)
if [[ -z "$VG_ID" ]]; then
echo "Creating variable group: $vg_name"
VG_ID=$(az pipelines variable-group create \
--name "$vg_name" \
--variables "${variables[@]}" \
--authorize true \
--query "id" -o tsv)
else
echo "Variable group exists: $vg_name (ID: $VG_ID)"
fi
echo "$VG_ID"
}Ensure Service Connection
# Check if service connection exists, create if not
ensure_service_connection() {
local name=$1
local project=$2
SC_ID=$(az devops service-endpoint list \
--project "$project" \
--query "[?name=='$name'].id" \
-o tsv)
if [[ -z "$SC_ID" ]]; then
echo "Service connection not found. Creating..."
# Create logic here
else
echo "Service connection exists: $name"
echo "$SC_ID"
fi
}Idempotent Work Item Creation
# Create work item only if doesn't exist with same title
create_work_item_if_new() {
local title=$1
local type=$2
WI_ID=$(az boards query \
--wiql "SELECT ID FROM WorkItems WHERE [System.WorkItemType]='$type' AND [System.Title]='$title'" \
--query "[0].id" -o tsv)
if [[ -z "$WI_ID" ]]; then
echo "Creating work item: $title"
WI_ID=$(az boards work-item create --title "$title" --type "$type" --query "id" -o tsv)
else
echo "Work item exists: $title (ID: $WI_ID)"
fi
echo "$WI_ID"
}Bulk Idempotent Operations
# Ensure multiple pipelines exist
declare -a PIPELINES=(
"ci-pipeline:azure-pipelines.yml"
"deploy-pipeline:deploy.yml"
"test-pipeline:test.yml"
)
for pipeline in "${PIPELINES[@]}"; do
IFS=':' read -r name yaml <<< "$pipeline"
ensure_pipeline "$name" "$yaml"
doneConfiguration Synchronization
# Sync variable groups from config file
sync_variable_groups() {
local config_file=$1
while IFS=',' read -r vg_name variables; do
ensure_variable_group "$vg_name" "$variables"
done < "$config_file"
}
# config.csv format:
# prod-vars,API_URL=prod.com,API_KEY=secret123
# dev-vars,API_URL=dev.com,API_KEY=secret456Real-World Workflows
CI/CD Pipeline Setup
# Setup complete CI/CD pipeline
setup_cicd_pipeline() {
local project=$1
local repo=$2
local branch=$3
# Create variable groups
VG_DEV=$(ensure_variable_group "dev-vars" "ENV=dev API_URL=api-dev.com")
VG_PROD=$(ensure_variable_group "prod-vars" "ENV=prod API_URL=api-prod.com")
# Create CI pipeline
az pipelines create \
--name "$repo-CI" \
--repository "$repo" \
--branch "$branch" \
--yaml-path .azure/pipelines/ci.yml \
--skip-run true
# Create CD pipeline
az pipelines create \
--name "$repo-CD" \
--repository "$repo" \
--branch "$branch" \
--yaml-path .azure/pipelines/cd.yml \
--skip-run true
echo "CI/CD pipeline setup complete"
}Automated PR Creation
# Create PR from feature branch with automation
create_automated_pr() {
local branch=$1
local title=$2
# Get branch info
LAST_COMMIT=$(git log -1 --pretty=%B "$branch")
COMMIT_SHA=$(git rev-parse "$branch")
# Find related work items
WORK_ITEMS=$(az boards query \
--wiql "SELECT ID FROM WorkItems WHERE [System.ChangedBy] = @Me AND [System.State] = 'Active'" \
--query "[].id" -o tsv)
# Create PR
PR_ID=$(az repos pr create \
--source-branch "$branch" \
--target-branch main \
--title "$title" \
--description "$LAST_COMMIT" \
--work-items $WORK_ITEMS \
--auto-complete true \
--query "pullRequestId" -o tsv)
# Set required reviewers
az repos pr reviewer add \
--id $PR_ID \
--reviewers $(git log -1 --pretty=format:'%ae' "$branch") \
--required true
echo "Created PR #$PR_ID"
}Pipeline Monitoring and Alerting
# Monitor pipeline and alert on failure
monitor_pipeline() {
local pipeline_name=$1
local slack_webhook=$2
while true; do
# Get latest run
RUN_ID=$(az pipelines list --query "[?name=='$pipeline_name'] | [0].id" -o tsv)
RUNS=$(az pipelines runs list --pipeline $RUN_ID --top 1)
LATEST_RUN_ID=$(echo "$RUNS" | jq -r '.[0].id')
RESULT=$(echo "$RUNS" | jq -r '.[0].result')
# Check if failed and not already processed
if [[ "$RESULT" == "failed" ]]; then
# Send Slack alert
curl -X POST "$slack_webhook" \
-H 'Content-Type: application/json' \
-d "{\"text\": \"Pipeline $pipeline_name failed! Run ID: $LATEST_RUN_ID\"}"
fi
sleep 300 # Check every 5 minutes
done
}Bulk Work Item Management
# Bulk update work items based on query
bulk_update_work_items() {
local wiql=$1
local updates=("$@")
# Query work items
WI_IDS=$(az boards query --wiql "$wiql" --query "[].id" -o tsv)
# Update each work item
for wi_id in $WI_IDS; do
az boards work-item update --id $wi_id "${updates[@]}"
echo "Updated work item: $wi_id"
done
}
# Usage: bulk_update_work_items "SELECT ID FROM WorkItems WHERE State='New'" --state "Active" --assigned-to "user@example.com"Branch Policy Automation
# Apply branch policies to all repositories
apply_branch_policies() {
local branch=$1
local project=$2
# Get all repositories
REPOS=$(az repos list --project "$project" --query "[].id" -o tsv)
for repo_id in $REPOS; do
echo "Applying policies to repo: $repo_id"
# Require minimum approvers
az repos policy approver-count create \
--blocking true \
--enabled true \
--branch "$branch" \
--repository-id "$repo_id" \
--minimum-approver-count 2 \
--creator-vote-counts true
# Require work item linking
az repos policy work-item-linking create \
--blocking true \
--branch "$branch" \
--enabled true \
--repository-id "$repo_id"
# Require build validation
BUILD_ID=$(az pipelines list --query "[?name=='CI'].id" -o tsv | head -1)
az repos policy build create \
--blocking true \
--enabled true \
--branch "$branch" \
--repository-id "$repo_id" \
--build-definition-id "$BUILD_ID" \
--queue-on-source-update-only true
done
}Multi-Environment Deployment
# Deploy across multiple environments
deploy_to_environments() {
local run_id=$1
shift
local environments=("$@")
# Download artifacts
ARTIFACT_NAME=$(az pipelines runs artifact list --run-id $run_id --query "[0].name" -o tsv)
az pipelines runs artifact download \
--artifact-name "$ARTIFACT_NAME" \
--path ./artifacts \
--run-id $run_id
# Deploy to each environment
for env in "${environments[@]}"; do
echo "Deploying to: $env"
# Get environment-specific variables
VG_ID=$(az pipelines variable-group list --query "[?name=='$env-vars'].id" -o tsv)
# Run deployment pipeline
DEPLOY_RUN_ID=$(az pipelines run \
--name "Deploy-$env" \
--variables ARTIFACT_PATH=./artifacts ENV="$env" \
--query "id" -o tsv)
# Wait for deployment
while true; do
STATUS=$(az pipelines runs show --run-id $DEPLOY_RUN_ID --query "status" -o tsv)
if [[ "$STATUS" != "inProgress" ]]; then
break
fi
sleep 10
done
done
}Related skills
How it compares
Use azure-devops-cli for Microsoft-hosted Azure DevOps org automation; pick Git-focused skills when only GitHub Actions and gh CLI are in scope.
FAQ
What Azure DevOps areas does azure-devops-cli cover?
azure-devops-cli documents Azure CLI commands for pipelines, repositories, boards, and artifacts, including output formats and JMESPath queries for machine-readable automation.
Which output formats does the az DevOps CLI support?
azure-devops-cli notes that az DevOps commands accept table, json, jsonc, yaml, and yamlc output, with JMESPath queries to filter fields for scripts and coding agents.
Is Azure Devops Cli safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.