azure-devops-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Azure DevOps CLI

Azure DevOps CLI

This Skill helps manage Azure DevOps resources using the Azure CLI with Azure DevOps extension.
CLI Version: 2.81.0 (current as of 2025)
本指南帮助你使用带有Azure DevOps扩展的Azure CLI来管理Azure DevOps资源。
CLI版本: 2.81.0(截至2025年为当前版本)

Prerequisites

前提条件

Install Azure CLI and Azure DevOps extension:
bash
undefined
安装Azure CLI和Azure DevOps扩展:
bash
undefined

Install Azure CLI

Install Azure CLI

brew install azure-cli # macOS curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # Linux pip install azure-cli # via pip
brew install azure-cli # macOS curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # Linux pip install azure-cli # via pip

Verify installation

Verify installation

az --version
az --version

Install Azure DevOps extension

Install Azure DevOps extension

az extension add --name azure-devops az extension show --name azure-devops
undefined
az extension add --name azure-devops az extension show --name azure-devops
undefined

CLI Structure

CLI结构

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 Packages
    ├── download   # Download packages
    └── publish    # Publish packages
az devops          # 主DevOps命令
├── admin          # 管理功能(横幅)
├── extension      # 扩展管理
├── project        # 团队项目
├── security       # 安全操作
│   ├── group      # 安全组
│   └── permission # 安全权限
├── service-endpoint # 服务连接
├── team           # 团队
├── user           # 用户
├── wiki           # 维基
├── configure      # 设置默认值
├── invoke         # 调用REST API
├── login          # 身份验证
└── logout         # 清除凭据

az pipelines       # Azure流水线
├── agent          # 代理
├── build          # 构建
├── folder         # 流水线文件夹
├── pool           # 代理池
├── queue          # 代理队列
├── release        # 发布
├── runs           # 流水线运行
├── variable       # 流水线变量
└── variable-group # 变量组

az boards          # Azure Boards
├── area           # 区域路径
├── iteration      # 迭代
└── work-item      # 工作项

az repos           # Azure代码库
├── import         # Git导入
├── policy         # 分支策略
├── pr             # 拉取请求
└── ref            # Git引用

az artifacts       # Azure制品
└── universal      # 通用包
    ├── download   # 下载包
    └── publish    # 发布包

Authentication

身份验证

Login to Azure DevOps

登录Azure DevOps

bash
undefined
bash
undefined

Interactive login (prompts for PAT)

交互式登录(提示输入PAT)

az devops login --organization https://dev.azure.com/{org}
az devops login --organization https://dev.azure.com/{org}

Login with PAT token

使用PAT令牌登录

az devops login --organization https://dev.azure.com/{org} --token YOUR_PAT_TOKEN
az devops login --organization https://dev.azure.com/{org} --token YOUR_PAT_TOKEN

Logout

登出

az devops logout --organization https://dev.azure.com/{org}
undefined
az devops logout --organization https://dev.azure.com/{org}
undefined

Configure Defaults

配置默认值

bash
undefined
bash
undefined

Set default organization and project

设置默认组织和项目

az devops configure --defaults organization=https://dev.azure.com/{org} project={project}
az devops configure --defaults organization=https://dev.azure.com/{org} project={project}

List current configuration

列出当前配置

az devops configure --list
az devops configure --list

Enable Git aliases

启用Git别名

az devops configure --use-git-aliases true
undefined
az devops configure --use-git-aliases true
undefined

Extension Management

扩展管理

List Extensions

列出扩展

bash
undefined
bash
undefined

List available extensions

列出可用扩展

az extension list-available --output table
az extension list-available --output table

List installed extensions

列出已安装扩展

az extension list --output table
undefined
az extension list --output table
undefined

Manage Azure DevOps Extension

管理Azure DevOps扩展

bash
undefined
bash
undefined

Install Azure DevOps extension

安装Azure DevOps扩展

az extension add --name azure-devops
az extension add --name azure-devops

Update Azure DevOps extension

更新Azure DevOps扩展

az extension update --name azure-devops
az extension update --name azure-devops

Remove extension

移除扩展

az extension remove --name azure-devops
az extension remove --name azure-devops

Install from local path

从本地路径安装

az extension add --source ~/extensions/azure-devops.whl
undefined
az extension add --source ~/extensions/azure-devops.whl
undefined

Projects

项目

List Projects

列出项目

bash
az devops project list --organization https://dev.azure.com/{org}
az devops project list --top 10 --output table
bash
az devops project list --organization https://dev.azure.com/{org}
az devops project list --top 10 --output table

Create Project

创建项目

bash
az devops project create \
  --name myNewProject \
  --organization https://dev.azure.com/{org} \
  --description "My new DevOps project" \
  --source-control git \
  --visibility private
bash
az devops project create \
  --name myNewProject \
  --organization https://dev.azure.com/{org} \
  --description "My new DevOps project" \
  --source-control git \
  --visibility private

Show Project Details

查看项目详情

bash
az devops project show --project {project-name} --org https://dev.azure.com/{org}
bash
az devops project show --project {project-name} --org https://dev.azure.com/{org}

Delete Project

删除项目

bash
az devops project delete --id {project-id} --org https://dev.azure.com/{org} --yes
bash
az devops project delete --id {project-id} --org https://dev.azure.com/{org} --yes

Repositories

代码库

List Repositories

列出代码库

bash
az repos list --org https://dev.azure.com/{org} --project {project}
az repos list --output table
bash
az repos list --org https://dev.azure.com/{org} --project {project}
az repos list --output table

Show Repository Details

查看代码库详情

bash
az repos show --repository {repo-name} --project {project}
bash
az repos show --repository {repo-name} --project {project}

Create Repository

创建代码库

bash
az repos create --name {repo-name} --project {project}
bash
az repos create --name {repo-name} --project {project}

Delete Repository

删除代码库

bash
az repos delete --id {repo-id} --project {project} --yes
bash
az repos delete --id {repo-id} --project {project} --yes

Update Repository

更新代码库

bash
az repos update --id {repo-id} --name {new-name} --project {project}
bash
az repos update --id {repo-id} --name {new-name} --project {project}

Repository Import

代码库导入

Import Git Repository

导入Git代码库

bash
undefined
bash
undefined

Import from public Git repository

从公共Git代码库导入

az repos import create
--git-source-url https://github.com/user/repo
--repository {repo-name}
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}
undefined
az repos import create
--git-source-url https://github.com/user/private-repo
--repository {repo-name}
--user {username}
--password {password-or-pat}
undefined

Pull Requests

拉取请求

Create Pull Request

创建拉取请求

bash
undefined
bash
undefined

Basic PR creation

基础PR创建

az repos pr create
--repository {repo}
--source-branch {source-branch}
--target-branch {target-branch}
--title "PR Title"
--description "PR description"
--open
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

关联工作项的PR

az repos pr create
--repository {repo}
--source-branch {source-branch}
--work-items 63 64
az repos pr create
--repository {repo}
--source-branch {source-branch}
--work-items 63 64

Draft PR with reviewers

带审阅者的草稿PR

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"
undefined
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"
undefined

List Pull Requests

列出拉取请求

bash
undefined
bash
undefined

All PRs

所有PR

az repos pr list --repository {repo}
az repos pr list --repository {repo}

Filter by status

按状态筛选

az repos pr list --repository {repo} --status active
az repos pr list --repository {repo} --status active

Filter by creator

按创建者筛选

az repos pr list --repository {repo} --creator {email}
az repos pr list --repository {repo} --creator {email}

Output as table

表格格式输出

az repos pr list --repository {repo} --output table
undefined
az repos pr list --repository {repo} --output table
undefined

Show PR Details

查看PR详情

bash
az repos pr show --id {pr-id}
az repos pr show --id {pr-id} --open  # Open in browser
bash
az repos pr show --id {pr-id}
az repos pr show --id {pr-id} --open  # 在浏览器中打开

Update PR (Complete/Abandon/Draft)

更新PR(完成/放弃/草稿)

bash
undefined
bash
undefined

Complete PR

完成PR

az repos pr update --id {pr-id} --status completed
az repos pr update --id {pr-id} --status completed

Abandon PR

放弃PR

az repos pr update --id {pr-id} --status abandoned
az repos pr update --id {pr-id} --status abandoned

Set to draft

设置为草稿

az repos pr update --id {pr-id} --draft true
az repos pr update --id {pr-id} --draft true

Publish draft PR

发布草稿PR

az repos pr update --id {pr-id} --draft false
az repos pr update --id {pr-id} --draft false

Auto-complete when policies pass

策略通过后自动完成

az repos pr update --id {pr-id} --auto-complete true
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"
undefined
az repos pr update --id {pr-id} --title "New title" --description "New description"
undefined

Checkout PR Locally

本地检出PR

bash
undefined
bash
undefined

Checkout PR branch

检出PR分支

az repos pr checkout --id {pr-id}
az repos pr checkout --id {pr-id}

Checkout with specific remote

使用特定远程检出

az repos pr checkout --id {pr-id} --remote-name upstream
undefined
az repos pr checkout --id {pr-id} --remote-name upstream
undefined

Vote on PR

对PR投票

bash
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 reset
bash
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 reset

PR Reviewers

PR审阅者

bash
undefined
bash
undefined

Add reviewers

添加审阅者

az repos pr reviewer add --id {pr-id} --reviewers user1@example.com user2@example.com
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}
az repos pr reviewer list --id {pr-id}

Remove reviewers

移除审阅者

az repos pr reviewer remove --id {pr-id} --reviewers user1@example.com
undefined
az repos pr reviewer remove --id {pr-id} --reviewers user1@example.com
undefined

PR Work Items

PR工作项

bash
undefined
bash
undefined

Add work items to PR

为PR添加工作项

az repos pr work-item add --id {pr-id} --work-items {id1} {id2}
az repos pr work-item add --id {pr-id} --work-items {id1} {id2}

List PR work items

列出PR关联的工作项

az repos pr work-item list --id {pr-id}
az repos pr work-item list --id {pr-id}

Remove work items from PR

从PR中移除工作项

az repos pr work-item remove --id {pr-id} --work-items {id1}
undefined
az repos pr work-item remove --id {pr-id} --work-items {id1}
undefined

PR Policies

PR策略

bash
undefined
bash
undefined

List policies for a PR

列出PR的策略

az repos pr policy list --id {pr-id}
az repos pr policy list --id {pr-id}

Queue policy evaluation for a PR

为PR排队策略评估

az repos pr policy queue --id {pr-id} --evaluation-id {evaluation-id}
undefined
az repos pr policy queue --id {pr-id} --evaluation-id {evaluation-id}
undefined

Pipelines

流水线

List Pipelines

列出流水线

bash
az pipelines list --output table
az pipelines list --query "[?name=='myPipeline']"
az pipelines list --folder-path 'folder/subfolder'
bash
az pipelines list --output table
az pipelines list --query "[?name=='myPipeline']"
az pipelines list --folder-path 'folder/subfolder'

Create Pipeline

创建流水线

bash
undefined
bash
undefined

From local repository context (auto-detects settings)

从本地代码库上下文创建(自动检测设置)

az pipelines create --name 'ContosoBuild' --description 'Pipeline for contoso project'
az pipelines create --name 'ContosoBuild' --description 'Pipeline for contoso project'

With specific branch and YAML path

指定分支和YAML路径创建

az pipelines create
--name {pipeline-name}
--repository {repo}
--branch main
--yaml-path azure-pipelines.yml
--description "My CI/CD pipeline"
az pipelines create
--name {pipeline-name}
--repository {repo}
--branch main
--yaml-path azure-pipelines.yml
--description "My CI/CD pipeline"

For GitHub repository

为GitHub代码库创建

az pipelines create
--name 'GitHubPipeline'
--repository https://github.com/Org/Repo
--branch main
--repository-type github
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 true
undefined
az pipelines create --name 'MyPipeline' --skip-run true
undefined

Show Pipeline

查看流水线

bash
az pipelines show --id {pipeline-id}
az pipelines show --name {pipeline-name}
bash
az pipelines show --id {pipeline-id}
az pipelines show --name {pipeline-name}

Update Pipeline

更新流水线

bash
az pipelines update --id {pipeline-id} --name "New name" --description "Updated description"
bash
az pipelines update --id {pipeline-id} --name "New name" --description "Updated description"

Delete Pipeline

删除流水线

bash
az pipelines delete --id {pipeline-id} --yes
bash
az pipelines delete --id {pipeline-id} --yes

Run Pipeline

运行流水线

bash
undefined
bash
undefined

Run by name

按名称运行

az pipelines run --name {pipeline-name} --branch main
az pipelines run --name {pipeline-name} --branch main

Run by ID

按ID运行

az pipelines run --id {pipeline-id} --branch refs/heads/main
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
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
az pipelines run --name {pipeline-name} --variables buildId=123 configuration=release

Open results in browser

在浏览器中打开结果

az pipelines run --name {pipeline-name} --open
undefined
az pipelines run --name {pipeline-name} --open
undefined

Pipeline Runs

流水线运行

List Runs

列出运行记录

bash
az pipelines runs list --pipeline {pipeline-id}
az pipelines runs list --name {pipeline-name} --top 10
az pipelines runs list --branch main --status completed
bash
az pipelines runs list --pipeline {pipeline-id}
az pipelines runs list --name {pipeline-name} --top 10
az pipelines runs list --branch main --status completed

Show Run Details

查看运行详情

bash
az pipelines runs show --run-id {run-id}
az pipelines runs show --run-id {run-id} --open
bash
az pipelines runs show --run-id {run-id}
az pipelines runs show --run-id {run-id} --open

Pipeline Artifacts

流水线制品

bash
undefined
bash
undefined

List artifacts for a run

列出某次运行的制品

az pipelines runs artifact list --run-id {run-id}
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}
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}
undefined
az pipelines runs artifact upload
--artifact-name '{artifact-name}'
--path {local-path}
--run-id {run-id}
undefined

Pipeline Run Tags

流水线运行标签

bash
undefined
bash
undefined

Add tag to run

为运行添加标签

az pipelines runs tag add --run-id {run-id} --tags production v1.0
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 table
undefined
az pipelines runs tag list --run-id {run-id} --output table
undefined

Builds

构建

List Builds

列出构建

bash
az pipelines build list
az pipelines build list --definition {build-definition-id}
az pipelines build list --status completed --result succeeded
bash
az pipelines build list
az pipelines build list --definition {build-definition-id}
az pipelines build list --status completed --result succeeded

Queue Build

排队构建

bash
az pipelines build queue --definition {build-definition-id} --branch main
az pipelines build queue --definition {build-definition-id} --parameters version=1.0.0
bash
az pipelines build queue --definition {build-definition-id} --branch main
az pipelines build queue --definition {build-definition-id} --parameters version=1.0.0

Show Build Details

查看构建详情

bash
az pipelines build show --id {build-id}
bash
az pipelines build show --id {build-id}

Cancel Build

取消构建

bash
az pipelines build cancel --id {build-id}
bash
az pipelines build cancel --id {build-id}

Build Tags

构建标签

bash
undefined
bash
undefined

Add tag to build

为构建添加标签

az pipelines build tag add --build-id {build-id} --tags prod release
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 prod
undefined
az pipelines build tag delete --build-id {build-id} --tag prod
undefined

Build Definitions

构建定义

List Build Definitions

列出构建定义

bash
az pipelines build definition list
az pipelines build definition list --name {definition-name}
bash
az pipelines build definition list
az pipelines build definition list --name {definition-name}

Show Build Definition

查看构建定义

bash
az pipelines build definition show --id {definition-id}
bash
az pipelines build definition show --id {definition-id}

Releases

发布

List Releases

列出发布

bash
az pipelines release list
az pipelines release list --definition {release-definition-id}
bash
az pipelines release list
az pipelines release list --definition {release-definition-id}

Create Release

创建发布

bash
az pipelines release create --definition {release-definition-id}
az pipelines release create --definition {release-definition-id} --description "Release v1.0"
bash
az pipelines release create --definition {release-definition-id}
az pipelines release create --definition {release-definition-id} --description "Release v1.0"

Show Release

查看发布

bash
az pipelines release show --id {release-id}
bash
az pipelines release show --id {release-id}

Release Definitions

发布定义

List Release Definitions

列出发布定义

bash
az pipelines release definition list
bash
az pipelines release definition list

Show Release Definition

查看发布定义

bash
az pipelines release definition show --id {definition-id}
bash
az pipelines release definition show --id {definition-id}

Pipeline Variables

流水线变量

List Variables

列出变量

bash
az pipelines variable list --pipeline-id {pipeline-id}
bash
az pipelines variable list --pipeline-id {pipeline-id}

Create Variable

创建变量

bash
undefined
bash
undefined

Non-secret variable

非机密变量

az pipelines variable create
--name {var-name}
--value {var-value}
--pipeline-id {pipeline-id}
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}
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}
undefined
az pipelines variable create
--name {var-name}
--secret true
--prompt true
--pipeline-id {pipeline-id}
undefined

Update Variable

更新变量

bash
az pipelines variable update \
  --name {var-name} \
  --value {new-value} \
  --pipeline-id {pipeline-id}
bash
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}
undefined
az pipelines variable update
--name {var-name}
--secret true
--value "{new-secret-value}"
--pipeline-id {pipeline-id}
undefined

Delete Variable

删除变量

bash
az pipelines variable delete --name {var-name} --pipeline-id {pipeline-id} --yes
bash
az pipelines variable delete --name {var-name} --pipeline-id {pipeline-id} --yes

Variable Groups

变量组

List Variable Groups

列出变量组

bash
az pipelines variable-group list
az pipelines variable-group list --output table
bash
az pipelines variable-group list
az pipelines variable-group list --output table

Show Variable Group

查看变量组

bash
az pipelines variable-group show --id {group-id}
bash
az pipelines variable-group show --id {group-id}

Create Variable Group

创建变量组

bash
az pipelines variable-group create \
  --name {group-name} \
  --variables key1=value1 key2=value2 \
  --authorize true
bash
az pipelines variable-group create \
  --name {group-name} \
  --variables key1=value1 key2=value2 \
  --authorize true

Update Variable Group

更新变量组

bash
az pipelines variable-group update \
  --id {group-id} \
  --name {new-name} \
  --description "Updated description"
bash
az pipelines variable-group update \
  --id {group-id} \
  --name {new-name} \
  --description "Updated description"

Delete Variable Group

删除变量组

bash
az pipelines variable-group delete --id {group-id} --yes
bash
az pipelines variable-group delete --id {group-id} --yes

Variable Group Variables

变量组变量

List Variables

列出变量

bash
az pipelines variable-group variable list --group-id {group-id}
bash
az pipelines variable-group variable list --group-id {group-id}

Create Variable

创建变量

bash
undefined
bash
undefined

Non-secret variable

非机密变量

az pipelines variable-group variable create
--group-id {group-id}
--name {var-name}
--value {var-value}
az pipelines variable-group variable create
--group-id {group-id}
--name {var-name}
--value {var-value}

Secret variable (will prompt for value if not provided)

机密变量(如果未提供值会提示输入)

az pipelines variable-group variable create
--group-id {group-id}
--name {var-name}
--secret true
az pipelines variable-group variable create
--group-id {group-id}
--name {var-name}
--secret true

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
undefined
export AZURE_DEVOPS_EXT_PIPELINE_VAR_MySecret=secretvalue az pipelines variable-group variable create
--group-id {group-id}
--name MySecret
--secret true
undefined

Update Variable

更新变量

bash
az pipelines variable-group variable update \
  --group-id {group-id} \
  --name {var-name} \
  --value {new-value} \
  --secret false
bash
az pipelines variable-group variable update \
  --group-id {group-id} \
  --name {var-name} \
  --value {new-value} \
  --secret false

Delete Variable

删除变量

bash
az pipelines variable-group variable delete \
  --group-id {group-id} \
  --name {var-name}
bash
az pipelines variable-group variable delete \
  --group-id {group-id} \
  --name {var-name}

Pipeline Folders

流水线文件夹

List Folders

列出文件夹

bash
az pipelines folder list
bash
az pipelines folder list

Create Folder

创建文件夹

bash
az pipelines folder create --path 'folder/subfolder' --description "My folder"
bash
az pipelines folder create --path 'folder/subfolder' --description "My folder"

Delete Folder

删除文件夹

bash
az pipelines folder delete --path 'folder/subfolder'
bash
az pipelines folder delete --path 'folder/subfolder'

Update Folder

更新文件夹

bash
az pipelines folder update --path 'old-folder' --new-path 'new-folder'
bash
az pipelines folder update --path 'old-folder' --new-path 'new-folder'

Agent Pools

代理池

List Agent Pools

列出代理池

bash
az pipelines pool list
az pipelines pool list --pool-type automation
az pipelines pool list --pool-type deployment
bash
az pipelines pool list
az pipelines pool list --pool-type automation
az pipelines pool list --pool-type deployment

Show Agent Pool

查看代理池

bash
az pipelines pool show --pool-id {pool-id}
bash
az pipelines pool show --pool-id {pool-id}

Agent Queues

代理队列

List Agent Queues

列出代理队列

bash
az pipelines queue list
az pipelines queue list --pool-name {pool-name}
bash
az pipelines queue list
az pipelines queue list --pool-name {pool-name}

Show Agent Queue

查看代理队列

bash
az pipelines queue show --id {queue-id}
bash
az pipelines queue show --id {queue-id}

Work Items (Boards)

工作项(Boards)

Query Work Items

查询工作项

bash
undefined
bash
undefined

WIQL query

WIQL查询

az boards query
--wiql "SELECT [System.Id], [System.Title], [System.State] FROM WorkItems WHERE [System.AssignedTo] = @Me AND [System.State] = 'Active'"
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 table
undefined
az boards query --wiql "SELECT * FROM WorkItems" --output table
undefined

Show Work Item

查看工作项

bash
az boards work-item show --id {work-item-id}
az boards work-item show --id {work-item-id} --open
bash
az boards work-item show --id {work-item-id}
az boards work-item show --id {work-item-id} --open

Create Work Item

创建工作项

bash
undefined
bash
undefined

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"
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"
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"
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"
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 --open
undefined
az boards work-item create --title "Bug" --type Bug --open
undefined

Update Work Item

更新工作项

bash
undefined
bash
undefined

Update state, title, and assignee

更新状态、标题和经办人

az boards work-item update
--id {work-item-id}
--state "Active"
--title "Updated title"
--assigned-to user@example.com
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}"
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"
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"
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"
undefined
az boards work-item update
--id {work-item-id}
--fields "Priority=1" "StoryPoints=5"
undefined

Delete Work Item

删除工作项

bash
undefined
bash
undefined

Soft delete (can be restored)

软删除(可恢复)

az boards work-item delete --id {work-item-id} --yes
az boards work-item delete --id {work-item-id} --yes

Permanent delete

永久删除

az boards work-item delete --id {work-item-id} --destroy --yes
undefined
az boards work-item delete --id {work-item-id} --destroy --yes
undefined

Work Item Relations

工作项关联

bash
undefined
bash
undefined

List relations

列出关联

az boards work-item relation list --id {work-item-id}
az boards work-item relation list --id {work-item-id}

List supported relation types

列出支持的关联类型

az boards work-item relation list-type
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}
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}
undefined
az boards work-item relation remove --id {work-item-id} --relation-id {relation-id}
undefined

Area Paths

区域路径

List Areas for Project

列出项目的区域

bash
az boards area project list --project {project}
az boards area project show --path "Project\\Area1" --project {project}
bash
az boards area project list --project {project}
az boards area project show --path "Project\\Area1" --project {project}

Create Area

创建区域

bash
az boards area project create --path "Project\\NewArea" --project {project}
bash
az boards area project create --path "Project\\NewArea" --project {project}

Update Area

更新区域

bash
az boards area project update \
  --path "Project\\OldArea" \
  --new-path "Project\\UpdatedArea" \
  --project {project}
bash
az boards area project update \
  --path "Project\\OldArea" \
  --new-path "Project\\UpdatedArea" \
  --project {project}

Delete Area

删除区域

bash
az boards area project delete --path "Project\\AreaToDelete" --project {project} --yes
bash
az boards area project delete --path "Project\\AreaToDelete" --project {project} --yes

Area Team Management

区域团队管理

bash
undefined
bash
undefined

List areas for team

列出团队的区域

az boards area team list --team {team-name} --project {project}
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}
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}
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 true
undefined
az boards area team update
--team {team-name}
--path "Project\Area"
--project {project}
--include-sub-areas true
undefined

Iterations

迭代

List Iterations for Project

列出项目的迭代

bash
az boards iteration project list --project {project}
az boards iteration project show --path "Project\\Sprint 1" --project {project}
bash
az boards iteration project list --project {project}
az boards iteration project show --path "Project\\Sprint 1" --project {project}

Create Iteration

创建迭代

bash
az boards iteration project create --path "Project\\Sprint 1" --project {project}
bash
az boards iteration project create --path "Project\\Sprint 1" --project {project}

Update Iteration

更新迭代

bash
az boards iteration project update \
  --path "Project\\OldSprint" \
  --new-path "Project\\NewSprint" \
  --project {project}
bash
az boards iteration project update \
  --path "Project\\OldSprint" \
  --new-path "Project\\NewSprint" \
  --project {project}

Delete Iteration

删除迭代

bash
az boards iteration project delete --path "Project\\OldSprint" --project {project} --yes
bash
az boards iteration project delete --path "Project\\OldSprint" --project {project} --yes

List Iterations for Team

列出团队的迭代

bash
az boards iteration team list --team {team-name} --project {project}
bash
az boards iteration team list --team {team-name} --project {project}

Add Iteration to Team

为团队添加迭代

bash
az boards iteration team add \
  --team {team-name} \
  --path "Project\\Sprint 1" \
  --project {project}
bash
az boards iteration team add \
  --team {team-name} \
  --path "Project\\Sprint 1" \
  --project {project}

Remove Iteration from Team

从团队中移除迭代

bash
az boards iteration team remove \
  --team {team-name} \
  --path "Project\\Sprint 1" \
  --project {project}
bash
az boards iteration team remove \
  --team {team-name} \
  --path "Project\\Sprint 1" \
  --project {project}

List Work Items in Iteration

列出迭代中的工作项

bash
az boards iteration team list-work-items \
  --team {team-name} \
  --path "Project\\Sprint 1" \
  --project {project}
bash
az boards iteration team list-work-items \
  --team {team-name} \
  --path "Project\\Sprint 1" \
  --project {project}

Set Default Iteration for Team

设置团队的默认迭代

bash
az boards iteration team set-default-iteration \
  --team {team-name} \
  --path "Project\\Sprint 1" \
  --project {project}
bash
az boards iteration team set-default-iteration \
  --team {team-name} \
  --path "Project\\Sprint 1" \
  --project {project}

Show Default Iteration

查看默认迭代

bash
az boards iteration team show-default-iteration \
  --team {team-name} \
  --project {project}
bash
az boards iteration team show-default-iteration \
  --team {team-name} \
  --project {project}

Set Backlog Iteration for Team

设置团队的待办事项迭代

bash
az boards iteration team set-backlog-iteration \
  --team {team-name} \
  --path "Project\\Sprint 1" \
  --project {project}
bash
az boards iteration team set-backlog-iteration \
  --team {team-name} \
  --path "Project\\Sprint 1" \
  --project {project}

Show Backlog Iteration

查看待办事项迭代

bash
az boards iteration team show-backlog-iteration \
  --team {team-name} \
  --project {project}
bash
az boards iteration team show-backlog-iteration \
  --team {team-name} \
  --project {project}

Show Current Iteration

查看当前迭代

bash
az boards iteration team show --team {team-name} --project {project} --timeframe current
bash
az boards iteration team show --team {team-name} --project {project} --timeframe current

Git References

Git引用

List References (Branches)

列出引用(分支)

bash
az repos ref list --repository {repo}
az repos ref list --repository {repo} --query "[?name=='refs/heads/main']"
bash
az repos ref list --repository {repo}
az repos ref list --repository {repo} --query "[?name=='refs/heads/main']"

Create Reference (Branch)

创建引用(分支)

bash
az repos ref create --name refs/heads/new-branch --object-type commit --object {commit-sha}
bash
az repos ref create --name refs/heads/new-branch --object-type commit --object {commit-sha}

Delete Reference (Branch)

删除引用(分支)

bash
az repos ref delete --name refs/heads/old-branch --repository {repo} --project {project}
bash
az repos ref delete --name refs/heads/old-branch --repository {repo} --project {project}

Lock Branch

锁定分支

bash
az repos ref lock --name refs/heads/main --repository {repo} --project {project}
bash
az repos ref lock --name refs/heads/main --repository {repo} --project {project}

Unlock Branch

解锁分支

bash
az repos ref unlock --name refs/heads/main --repository {repo} --project {project}
bash
az repos ref unlock --name refs/heads/main --repository {repo} --project {project}

Repository Policies

代码库策略

List All Policies

列出所有策略

bash
az repos policy list --repository {repo-id} --branch main
bash
az repos policy list --repository {repo-id} --branch main

Create Policy Using Configuration File

使用配置文件创建策略

bash
az repos policy create --config policy.json
bash
az repos policy create --config policy.json

Update/Delete Policy

更新/删除策略

bash
undefined
bash
undefined

Update

更新

az repos policy update --id {policy-id} --config updated-policy.json
az repos policy update --id {policy-id} --config updated-policy.json

Delete

删除

az repos policy delete --id {policy-id} --yes
undefined
az repos policy delete --id {policy-id} --yes
undefined

Policy Types

策略类型

Approver Count Policy

审批者数量策略

bash
az repos policy approver-count create \
  --blocking true \
  --enabled true \
  --branch main \
  --repository-id {repo-id} \
  --minimum-approver-count 2 \
  --creator-vote-counts true
bash
az repos policy approver-count create \
  --blocking true \
  --enabled true \
  --branch main \
  --repository-id {repo-id} \
  --minimum-approver-count 2 \
  --creator-vote-counts true

Build Policy

构建策略

bash
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 720
bash
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 720

Work Item Linking Policy

工作项关联策略

bash
az repos policy work-item-linking create \
  --blocking true \
  --branch main \
  --enabled true \
  --repository-id {repo-id}
bash
az repos policy work-item-linking create \
  --blocking true \
  --branch main \
  --enabled true \
  --repository-id {repo-id}

Required Reviewer Policy

必填审阅者策略

bash
az repos policy required-reviewer create \
  --blocking true \
  --enabled true \
  --branch main \
  --repository-id {repo-id} \
  --required-reviewers user@example.com
bash
az repos policy required-reviewer create \
  --blocking true \
  --enabled true \
  --branch main \
  --repository-id {repo-id} \
  --required-reviewers user@example.com

Merge Strategy Policy

合并策略

bash
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 true
bash
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 true

Case Enforcement Policy

大小写强制策略

bash
az repos policy case-enforcement create \
  --blocking true \
  --enabled true \
  --branch main \
  --repository-id {repo-id}
bash
az repos policy case-enforcement create \
  --blocking true \
  --enabled true \
  --branch main \
  --repository-id {repo-id}

Comment Required Policy

评论必填策略

bash
az repos policy comment-required create \
  --blocking true \
  --enabled true \
  --branch main \
  --repository-id {repo-id}
bash
az repos policy comment-required create \
  --blocking true \
  --enabled true \
  --branch main \
  --repository-id {repo-id}

File Size Policy

文件大小策略

bash
az repos policy file-size create \
  --blocking true \
  --enabled true \
  --branch main \
  --repository-id {repo-id} \
  --maximum-file-size 10485760  # 10MB in bytes
bash
az repos policy file-size create \
  --blocking true \
  --enabled true \
  --branch main \
  --repository-id {repo-id} \
  --maximum-file-size 10485760  # 10MB in bytes

Service Endpoints

服务端点

List Service Endpoints

列出服务端点

bash
az devops service-endpoint list --project {project}
az devops service-endpoint list --project {project} --output table
bash
az devops service-endpoint list --project {project}
az devops service-endpoint list --project {project} --output table

Show Service Endpoint

查看服务端点

bash
az devops service-endpoint show --id {endpoint-id} --project {project}
bash
az devops service-endpoint show --id {endpoint-id} --project {project}

Create Service Endpoint

创建服务端点

bash
undefined
bash
undefined

Using configuration file

使用配置文件

az devops service-endpoint create --service-endpoint-configuration endpoint.json --project {project}
undefined
az devops service-endpoint create --service-endpoint-configuration endpoint.json --project {project}
undefined

Delete Service Endpoint

删除服务端点

bash
az devops service-endpoint delete --id {endpoint-id} --project {project} --yes
bash
az devops service-endpoint delete --id {endpoint-id} --project {project} --yes

Teams

团队

List Teams

列出团队

bash
az devops team list --project {project}
bash
az devops team list --project {project}

Show Team

查看团队

bash
az devops team show --team {team-name} --project {project}
bash
az devops team show --team {team-name} --project {project}

Create Team

创建团队

bash
az devops team create \
  --name {team-name} \
  --description "Team description" \
  --project {project}
bash
az devops team create \
  --name {team-name} \
  --description "Team description" \
  --project {project}

Update Team

更新团队

bash
az devops team update \
  --team {team-name} \
  --project {project} \
  --name "{new-team-name}" \
  --description "Updated description"
bash
az devops team update \
  --team {team-name} \
  --project {project} \
  --name "{new-team-name}" \
  --description "Updated description"

Delete Team

删除团队

bash
az devops team delete --team {team-name} --project {project} --yes
bash
az devops team delete --team {team-name} --project {project} --yes

Show Team Members

查看团队成员

bash
az devops team list-member --team {team-name} --project {project}
bash
az devops team list-member --team {team-name} --project {project}

Users

用户

List Users

列出用户

bash
az devops user list --org https://dev.azure.com/{org}
az devops user list --top 10 --output table
bash
az devops user list --org https://dev.azure.com/{org}
az devops user list --top 10 --output table

Show User

查看用户

bash
az devops user show --user {user-id-or-email} --org https://dev.azure.com/{org}
bash
az devops user show --user {user-id-or-email} --org https://dev.azure.com/{org}

Add User

添加用户

bash
az devops user add \
  --email user@example.com \
  --license-type express \
  --org https://dev.azure.com/{org}
bash
az devops user add \
  --email user@example.com \
  --license-type express \
  --org https://dev.azure.com/{org}

Update User

更新用户

bash
az devops user update \
  --user {user-id-or-email} \
  --license-type advanced \
  --org https://dev.azure.com/{org}
bash
az devops user update \
  --user {user-id-or-email} \
  --license-type advanced \
  --org https://dev.azure.com/{org}

Remove User

移除用户

bash
az devops user remove --user {user-id-or-email} --org https://dev.azure.com/{org} --yes
bash
az devops user remove --user {user-id-or-email} --org https://dev.azure.com/{org} --yes

Security Groups

安全组

List Groups

列出组

bash
undefined
bash
undefined

List all groups in project

列出项目中的所有组

az devops security group list --project {project}
az devops security group list --project {project}

List all groups in organization

列出组织中的所有组

az devops security group list --scope organization
az devops security group list --scope organization

List with filtering

带筛选的列出

az devops security group list --project {project} --subject-types vstsgroup
undefined
az devops security group list --project {project} --subject-types vstsgroup
undefined

Show Group Details

查看组详情

bash
az devops security group show --group-id {group-id}
bash
az devops security group show --group-id {group-id}

Create Group

创建组

bash
az devops security group create \
  --name {group-name} \
  --description "Group description" \
  --project {project}
bash
az devops security group create \
  --name {group-name} \
  --description "Group description" \
  --project {project}

Update Group

更新组

bash
az devops security group update \
  --group-id {group-id} \
  --name "{new-group-name}" \
  --description "Updated description"
bash
az devops security group update \
  --group-id {group-id} \
  --name "{new-group-name}" \
  --description "Updated description"

Delete Group

删除组

bash
az devops security group delete --group-id {group-id} --yes
bash
az devops security group delete --group-id {group-id} --yes

Group Memberships

组成员

bash
undefined
bash
undefined

List memberships

列出成员

az devops security group membership list --id {group-id}
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}
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} --yes
undefined
az devops security group membership remove
--group-id {group-id}
--member-id {member-id} --yes
undefined

Security Permissions

安全权限

List Namespaces

列出命名空间

bash
az devops security permission namespace list
bash
az devops security permission namespace list

Show Namespace Details

查看命名空间详情

bash
undefined
bash
undefined

Show permissions available in a namespace

查看命名空间中可用的权限

az devops security permission namespace show --namespace "GitRepositories"
undefined
az devops security permission namespace show --namespace "GitRepositories"
undefined

List Permissions

列出权限

bash
undefined
bash
undefined

List permissions for user/group and namespace

列出用户/组和命名空间的权限

az devops security permission list
--id {user-or-group-id}
--namespace "GitRepositories"
--project {project}
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}"
undefined
az devops security permission list
--id {user-or-group-id}
--namespace "GitRepositories"
--project {project}
--token "repoV2/{project}/{repository-id}"
undefined

Show Permissions

查看权限

bash
az devops security permission show \
  --id {user-or-group-id} \
  --namespace "GitRepositories" \
  --project {project} \
  --token "repoV2/{project}/{repository-id}"
bash
az devops security permission show \
  --id {user-or-group-id} \
  --namespace "GitRepositories" \
  --project {project} \
  --token "repoV2/{project}/{repository-id}"

Update Permissions

更新权限

bash
undefined
bash
undefined

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"
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 0
undefined
az devops security permission update
--id {user-or-group-id}
--namespace "GitRepositories"
--project {project}
--token "repoV2/{project}/{repository-id}"
--permission-mask 0
undefined

Reset Permissions

重置权限

bash
undefined
bash
undefined

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"
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}" --yes
undefined
az devops security permission reset-all
--id {user-or-group-id}
--namespace "GitRepositories"
--project {project}
--token "repoV2/{project}/{repository-id}" --yes
undefined

Wikis

维基

List Wikis

列出维基

bash
undefined
bash
undefined

List all wikis in project

列出项目中的所有维基

az devops wiki list --project {project}
az devops wiki list --project {project}

List all wikis in organization

列出组织中的所有维基

az devops wiki list
undefined
az devops wiki list
undefined

Show Wiki

查看维基

bash
az devops wiki show --wiki {wiki-name} --project {project}
az devops wiki show --wiki {wiki-name} --project {project} --open
bash
az devops wiki show --wiki {wiki-name} --project {project}
az devops wiki show --wiki {wiki-name} --project {project} --open

Create Wiki

创建维基

bash
undefined
bash
undefined

Create project wiki

创建项目维基

az devops wiki create
--name {wiki-name}
--project {project}
--type projectWiki
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 /wiki
undefined
az devops wiki create
--name {wiki-name}
--project {project}
--type codeWiki
--repository {repo-name}
--mapped-path /wiki
undefined

Delete Wiki

删除维基

bash
az devops wiki delete --wiki {wiki-id} --project {project} --yes
bash
az devops wiki delete --wiki {wiki-id} --project {project} --yes

Wiki Pages

维基页面

bash
undefined
bash
undefined

List pages

列出页面

az devops wiki page list --wiki {wiki-name} --project {project}
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}
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}
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}
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} --yes
undefined
az devops wiki page delete
--wiki {wiki-name}
--path "/old-page"
--project {project} --yes
undefined

Administration

管理功能

Banner Management

横幅管理

bash
undefined
bash
undefined

List banners

列出横幅

az devops admin banner list
az devops admin banner list

Show banner details

查看横幅详情

az devops admin banner show --id {banner-id}
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
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"
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}
undefined
az devops admin banner remove --id {banner-id}
undefined

DevOps Extensions

DevOps扩展

Manage extensions installed in an Azure DevOps organization (different from CLI extensions).
bash
undefined
管理Azure DevOps组织中安装的扩展(与CLI扩展不同)。
bash
undefined

List installed extensions

列出已安装的扩展

az devops extension list --org https://dev.azure.com/{org}
az devops extension list --org https://dev.azure.com/{org}

Search marketplace extensions

搜索市场扩展

az devops extension search --search-query "docker"
az devops extension search --search-query "docker"

Show extension details

查看扩展详情

az devops extension show --ext-id {extension-id} --org https://dev.azure.com/{org}
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}
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}
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}
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} --yes
undefined
az devops extension uninstall
--ext-id {extension-id}
--org https://dev.azure.com/{org} --yes
undefined

Universal Packages

通用包

Publish Package

发布包

bash
az artifacts universal publish \
  --feed {feed-name} \
  --name {package-name} \
  --version {version} \
  --path {package-path} \
  --project {project}
bash
az artifacts universal publish \
  --feed {feed-name} \
  --name {package-name} \
  --version {version} \
  --path {package-path} \
  --project {project}

Download Package

下载包

bash
az artifacts universal download \
  --feed {feed-name} \
  --name {package-name} \
  --version {version} \
  --path {download-path} \
  --project {project}
bash
az artifacts universal download \
  --feed {feed-name} \
  --name {package-name} \
  --version {version} \
  --path {download-path} \
  --project {project}

Agents

代理

List Agents in Pool

列出池中的代理

bash
az pipelines agent list --pool-id {pool-id}
bash
az pipelines agent list --pool-id {pool-id}

Show Agent Details

查看代理详情

bash
az pipelines agent show --agent-id {agent-id} --pool-id {pool-id}
bash
az pipelines agent show --agent-id {agent-id} --pool-id {pool-id}

Git Aliases

Git别名

After enabling git aliases:
bash
undefined
启用Git别名后:
bash
undefined

Enable Git aliases

启用Git别名

az devops configure --use-git-aliases true
az devops configure --use-git-aliases true

Use Git commands for DevOps operations

使用Git命令执行DevOps操作

git pr create --target-branch main git pr list git pr checkout 123
undefined
git pr create --target-branch main git pr list git pr checkout 123
undefined

Output Formats

输出格式

All commands support multiple output formats:
bash
undefined
所有命令支持多种输出格式:
bash
undefined

Table format (human-readable)

表格格式(人类可读)

az pipelines list --output table
az pipelines list --output table

JSON format (default, machine-readable)

JSON格式(默认,机器可读)

az pipelines list --output json
az pipelines list --output json

JSONC (colored JSON)

JSONC(带颜色的JSON)

az pipelines list --output jsonc
az pipelines list --output jsonc

YAML format

YAML格式

az pipelines list --output yaml
az pipelines list --output yaml

YAMLC (colored YAML)

YAMLC(带颜色的YAML)

az pipelines list --output yamlc
az pipelines list --output yamlc

TSV format (tab-separated values)

TSV格式(制表符分隔值)

az pipelines list --output tsv
az pipelines list --output tsv

None (no output)

无输出

az pipelines list --output none
undefined
az pipelines list --output none
undefined

JMESPath Queries

JMESPath查询

Filter and transform output:
bash
undefined
筛选和转换输出:
bash
undefined

Filter by name

按名称筛选

az pipelines list --query "[?name=='myPipeline']"
az pipelines list --query "[?name=='myPipeline']"

Get specific fields

获取特定字段

az pipelines list --query "[].{Name:name, ID:id}"
az pipelines list --query "[].{Name:name, ID:id}"

Chain queries

链式查询

az pipelines list --query "[?name.contains('CI')].{Name:name, ID:id}" --output table
az pipelines list --query "[?name.contains('CI')].{Name:name, ID:id}" --output table

Get first result

获取第一个结果

az pipelines list --query "[0]"
az pipelines list --query "[0]"

Get top N

获取前N个结果

az pipelines list --query "[0:5]"
undefined
az pipelines list --query "[0:5]"
undefined

Global Arguments

全局参数

Available on all commands:
  • --help
    /
    -h
    : Show help
  • --output
    /
    -o
    : Output format (json, jsonc, none, table, tsv, yaml, yamlc)
  • --query
    : JMESPath query string
  • --verbose
    : Increase logging verbosity
  • --debug
    : Show all debug logs
  • --only-show-errors
    : Only show errors, suppress warnings
  • --subscription
    : Name or ID of subscription
所有命令都支持:
  • --help
    /
    -h
    : 显示帮助
  • --output
    /
    -o
    : 输出格式(json, jsonc, none, table, tsv, yaml, yamlc)
  • --query
    : JMESPath查询字符串
  • --verbose
    : 增加日志详细程度
  • --debug
    : 显示所有调试日志
  • --only-show-errors
    : 仅显示错误,抑制警告
  • --subscription
    : 订阅名称或ID

Common Parameters

通用参数

ParameterDescription
--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 in web browser
参数描述
--org
/
--organization
Azure DevOps组织URL(例如:
https://dev.azure.com/{org}
--project
/
-p
项目名称或ID
--detect
从git配置自动检测组织
--yes
/
-y
跳过确认提示
--open
在浏览器中打开

Common Workflows

常见工作流

Create PR from current branch

从当前分支创建PR

bash
CURRENT_BRANCH=$(git branch --show-current)
az repos pr create \
  --source-branch $CURRENT_BRANCH \
  --target-branch main \
  --title "Feature: $(git log -1 --pretty=%B)" \
  --open
bash
CURRENT_BRANCH=$(git branch --show-current)
az repos pr create \
  --source-branch $CURRENT_BRANCH \
  --target-branch main \
  --title "Feature: $(git log -1 --pretty=%B)" \
  --open

Create work item on pipeline failure

流水线失败时创建工作项

bash
az boards work-item create \
  --title "Build $BUILD_BUILDNUMBER failed" \
  --type bug \
  --org $SYSTEM_TEAMFOUNDATIONCOLLECTIONURI \
  --project $SYSTEM_TEAMPROJECT
bash
az boards work-item create \
  --title "Build $BUILD_BUILDNUMBER failed" \
  --type bug \
  --org $SYSTEM_TEAMFOUNDATIONCOLLECTIONURI \
  --project $SYSTEM_TEAMPROJECT

Download latest pipeline artifact

下载最新流水线制品

bash
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_ID
bash
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_ID

Approve and complete PR

批准并完成PR

bash
undefined
bash
undefined

Vote approve

投票批准

az repos pr set-vote --id {pr-id} --vote approve
az repos pr set-vote --id {pr-id} --vote approve

Complete PR

完成PR

az repos pr update --id {pr-id} --status completed
undefined
az repos pr update --id {pr-id} --status completed
undefined

Create pipeline from local repo

从本地代码库创建流水线

bash
undefined
bash
undefined

From local git repository (auto-detects repo, branch, etc.)

从本地git代码库创建(自动检测代码库、分支等)

az pipelines create --name 'CI-Pipeline' --description 'Continuous Integration'
undefined
az pipelines create --name 'CI-Pipeline' --description 'Continuous Integration'
undefined

Bulk update work items

批量更新工作项

bash
undefined
bash
undefined

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" done
undefined
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" done
undefined

Best Practices

最佳实践

Authentication and Security

身份验证和安全

bash
undefined
bash
undefined

Use PAT from environment variable (most secure)

使用环境变量中的PAT(最安全)

export AZURE_DEVOPS_EXT_PAT=$MY_PAT az devops login --organization $ORG_URL
export AZURE_DEVOPS_EXT_PAT=$MY_PAT az devops login --organization $ORG_URL

Pipe PAT securely (avoids shell history)

安全地传递PAT(避免出现在shell历史中)

echo $MY_PAT | az devops login --organization $ORG_URL
echo $MY_PAT | az devops login --organization $ORG_URL

Set defaults to avoid repetition

设置默认值以避免重复输入

az devops configure --defaults organization=$ORG_URL project=$PROJECT
az devops configure --defaults organization=$ORG_URL project=$PROJECT

Clear credentials after use

使用后清除凭据

az devops logout --organization $ORG_URL
undefined
az devops logout --organization $ORG_URL
undefined

Idempotent Operations

幂等操作

bash
undefined
bash
undefined

Always use --detect for auto-detection

始终使用--detect进行自动检测

az devops configure --defaults organization=$ORG_URL project=$PROJECT
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
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

使用--output tsv进行shell解析

PIPELINE_ID=$(az pipelines list --query "[?name=='MyPipeline'].id" --output tsv)
PIPELINE_ID=$(az pipelines list --query "[?name=='MyPipeline'].id" --output tsv)

Use --output json for programmatic access

使用--output json进行程序化访问

BUILD_STATUS=$(az pipelines build show --id $BUILD_ID --query "status" --output json)
undefined
BUILD_STATUS=$(az pipelines build show --id $BUILD_ID --query "status" --output json)
undefined

Script-Safe Output

脚本安全输出

bash
undefined
bash
undefined

Suppress warnings and errors

抑制警告和错误

az pipelines list --only-show-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
az pipelines run --name "$PIPELINE_NAME" --output none

TSV format for shell scripts (clean, no formatting)

TSV格式(适用于shell脚本,无格式)

az repos pr list --output tsv --query "[].{ID:pullRequestId,Title:title}"
az repos pr list --output tsv --query "[].{ID:pullRequestId,Title:title}"

JSON with specific fields

带特定字段的JSON

az pipelines list --output json --query "[].{Name:name, ID:id, URL:url}"
undefined
az pipelines list --output json --query "[].{Name:name, ID:id, URL:url}"
undefined

Pipeline Orchestration

流水线编排

bash
undefined
bash
undefined

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
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 fi
undefined
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 fi
undefined

Variable Group Management

变量组管理

bash
undefined
bash
undefined

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" fi
undefined
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" fi
undefined

Service Connection Automation

服务连接自动化

bash
undefined
bash
undefined

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"
undefined
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"
undefined

Pull Request Automation

拉取请求自动化

bash
undefined
bash
undefined

Create PR with work items and reviewers

创建关联工作项和审阅者的PR

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)
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 true
undefined
az repos pr update --id $PR_ID --auto-complete true
undefined

Error Handling and Retry Patterns

错误处理和重试模式

Retry Logic for Transient Failures

瞬时故障的重试逻辑

bash
undefined
bash
undefined

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 }
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"
undefined
retry_command az pipelines run --name "$PIPELINE_NAME"
undefined

Check and Handle Errors

检查并处理错误

bash
undefined
bash
undefined

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" fi
undefined
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" fi
undefined

Validate Inputs

验证输入

bash
undefined
bash
undefined

Validate required parameters

验证必填参数

if [[ -z "$PROJECT" || -z "$REPO" ]]; then echo "Error: PROJECT and REPO must be set" exit 1 fi
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 fi
undefined
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 fi
undefined

Handle Permission Errors

处理权限错误

bash
undefined
bash
undefined

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 fi
undefined
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 fi
undefined

Pipeline Failure Notification

流水线失败通知

bash
undefined
bash
undefined

Run pipeline and check result

运行流水线并检查结果

RUN_ID=$(az pipelines run --name "$PIPELINE_NAME" --query "id" -o tsv)
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
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" fi
undefined
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" fi
undefined

Graceful Degradation

优雅降级

bash
undefined
bash
undefined

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 fi
undefined
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..."

备用下载方法

curl -L "$BACKUP_URL" -o ./output/backup.zip fi
undefined

Advanced JMESPath Queries

高级JMESPath查询

Filtering and Sorting

筛选和排序

bash
undefined
bash
undefined

Filter by multiple conditions

多条件筛选

az pipelines list --query "[?name.contains('CI') && enabled==true]"
az pipelines list --query "[?name.contains('CI') && enabled==true]"

Filter by status and result

按状态和结果筛选

az pipelines runs list --query "[?status=='completed' && result=='succeeded']"
az pipelines runs list --query "[?status=='completed' && result=='succeeded']"

Sort by date (descending)

按日期排序(降序)

az pipelines runs list --query "sort_by([?status=='completed'], &finishTime | reverse(@))"
az pipelines runs list --query "sort_by([?status=='completed'], &finishTime | reverse(@))"

Get top N items after filtering

筛选后获取前N个项目

az pipelines runs list --query "[?result=='succeeded'] | [0:5]"
undefined
az pipelines runs list --query "[?result=='succeeded'] | [0:5]"
undefined

Nested Queries

嵌套查询

bash
undefined
bash
undefined

Extract nested properties

提取嵌套属性

az pipelines show --id $PIPELINE_ID --query "{Name:name, Repo:repository.{Name:name, Type:type}, Folder:folder}"
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}"
undefined
az pipelines build show --id $BUILD_ID --query "{ID:id, Number:buildNumber, Status:status, Result:result, Requested:requestedFor.displayName}"
undefined

Complex Filtering

复杂筛选

bash
undefined
bash
undefined

Find pipelines with specific YAML path

查找具有特定YAML路径的流水线

az pipelines list --query "[?process.type.name=='yaml' && process.yamlFilename=='azure-pipelines.yml']"
az pipelines list --query "[?process.type.name=='yaml' && process.yamlFilename=='azure-pipelines.yml']"

Find PRs from specific reviewer

查找来自特定审阅者的PR

az repos pr list --query "[?contains(reviewers[?displayName=='John Doe'].displayName, 'John Doe')]"
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']}"
undefined
az boards work-item show --id $WI_ID --query "{Title:fields['System.Title'], State:fields['System.State'], Iteration:fields['System.IterationPath']}"
undefined

Aggregation

聚合

bash
undefined
bash
undefined

Count items by status

按状态统计项目数量

az pipelines runs list --query "groupBy([?status=='completed'], &[result]) | {Succeeded: [?key=='succeeded'][0].count, Failed: [?key=='failed'][0].count}"
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)"
az repos pr list --query "unique_by(reviewers[], &displayName)"

Sum values

求和

az pipelines runs list --query "[?result=='succeeded'] | [].{Duration:duration} | [0].Duration"
undefined
az pipelines runs list --query "[?result=='succeeded'] | [].{Duration:duration} | [0].Duration"
undefined

Conditional Transformation

条件转换

bash
undefined
bash
undefined

Format dates

格式化日期

az pipelines runs list --query "[].{ID:id, Date:createdDate, Formatted:createdDate | format_datetime(@, 'yyyy-MM-dd HH:mm')}"
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')}"
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'}"
undefined
az pipelines show --id $PIPELINE_ID --query "{Name:name, Folder:folder || 'Root', Description:description || 'No description'}"
undefined

Complex Workflows

复杂工作流

bash
undefined
bash
undefined

Find longest running builds

查找运行时间最长的构建

az pipelines build list --query "sort_by([?result=='succeeded'], &queueTime) | reverse(@) | [0:3].{ID:id, Number:buildNumber, Duration:duration}"
az pipelines build list --query "sort_by([?result=='succeeded'], &queueTime) | reverse(@) | [0:3].{ID:id, Number:buildNumber, Duration:duration}"

Get PR statistics per reviewer

获取每位审阅者的PR统计

az repos pr list --query "groupBy([], &reviewers[].displayName) | [].{Reviewer:@.key, Count:length(@)}"
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]}"
undefined
az boards work-item relation list --id $PARENT_ID --query "[?rel=='System.LinkTypes.Hierarchy-Forward'] | [].{ChildID:url | split('/', @) | [-1]}"
undefined

Scripting Patterns for Idempotent Operations

幂等操作的脚本模式

Create or Update Pattern

创建或更新模式

bash
undefined
bash
undefined

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 }
undefined
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 }
undefined

Ensure Variable Group

确保变量组存在

bash
undefined
bash
undefined

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" }
undefined
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" }
undefined

Ensure Service Connection

确保服务连接存在

bash
undefined
bash
undefined

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 }
undefined
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..." # 此处添加创建逻辑 else echo "Service connection exists: $name" echo "$SC_ID" fi }
undefined

Idempotent Work Item Creation

幂等创建工作项

bash
undefined
bash
undefined

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" }
undefined
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" }
undefined

Bulk Idempotent Operations

批量幂等操作

bash
undefined
bash
undefined

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" done
undefined
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" done
undefined

Configuration Synchronization

配置同步

bash
undefined
bash
undefined

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" }
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:

config.csv格式:

prod-vars,API_URL=prod.com,API_KEY=secret123

prod-vars,API_URL=prod.com,API_KEY=secret123

dev-vars,API_URL=dev.com,API_KEY=secret456

dev-vars,API_URL=dev.com,API_KEY=secret456

undefined
undefined

Real-World Workflows

实际工作流

CI/CD Pipeline Setup

CI/CD流水线设置

bash
undefined
bash
undefined

Setup complete CI/CD pipeline

设置完整的CI/CD流水线

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" }
undefined
setup_cicd_pipeline() { local project=$1 local repo=$2 local branch=$3

创建变量组

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")

创建CI流水线

az pipelines create
--name "$repo-CI"
--repository "$repo"
--branch "$branch"
--yaml-path .azure/pipelines/ci.yml
--skip-run true

创建CD流水线

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" }
undefined

Automated PR Creation

自动化PR创建

bash
undefined
bash
undefined

Create PR from feature branch with automation

从功能分支自动化创建PR

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" }
undefined
create_automated_pr() { local branch=$1 local title=$2

获取分支信息

LAST_COMMIT=$(git log -1 --pretty=%B "$branch") COMMIT_SHA=$(git rev-parse "$branch")

查找关联的工作项

WORK_ITEMS=$(az boards query
--wiql "SELECT ID FROM WorkItems WHERE [System.ChangedBy] = @Me AND [System.State] = 'Active'"
--query "[].id" -o tsv)

创建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)

设置必填审阅者

az repos pr reviewer add
--id $PR_ID
--reviewers $(git log -1 --pretty=format:'%ae' "$branch")
--required true
echo "Created PR #$PR_ID" }
undefined

Pipeline Monitoring and Alerting

流水线监控和告警

bash
undefined
bash
undefined

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 }
undefined
monitor_pipeline() { local pipeline_name=$1 local slack_webhook=$2
while true; do # 获取最新运行记录 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')

# 检查是否失败且未处理
if [[ "$RESULT" == "failed" ]]; then
  # 发送Slack告警
  curl -X POST "$slack_webhook" \
    -H 'Content-Type: application/json' \
    -d "{\"text\": \"Pipeline $pipeline_name failed! Run ID: $LATEST_RUN_ID\"}"
fi

sleep 300 # 每5分钟检查一次
done }
undefined

Bulk Work Item Management

批量工作项管理

bash
undefined
bash
undefined

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 }
bulk_update_work_items() { local wiql=$1 shift local updates=("$@")

查询工作项

WI_IDS=$(az boards query --wiql "$wiql" --query "[].id" -o tsv)

更新每个工作项

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"

使用示例: bulk_update_work_items "SELECT ID FROM WorkItems WHERE State='New'" --state "Active" --assigned-to "user@example.com"

undefined
undefined

Branch Policy Automation

分支策略自动化

bash
undefined
bash
undefined

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 }
undefined
apply_branch_policies() { local branch=$1 local project=$2

获取所有代码库

REPOS=$(az repos list --project "$project" --query "[].id" -o tsv)
for repo_id in $REPOS; do echo "Applying policies to repo: $repo_id"
# 要求最少审批者数量
az repos policy approver-count create \
  --blocking true \
  --enabled true \
  --branch "$branch" \
  --repository-id "$repo_id" \
  --minimum-approver-count 2 \
  --creator-vote-counts true

# 要求工作项关联
az repos policy work-item-linking create \
  --blocking true \
  --branch "$branch" \
  --enabled true \
  --repository-id "$repo_id"

# 要求构建验证
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 }
undefined

Multi-Environment Deployment

多环境部署

bash
undefined
bash
undefined

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 }
undefined
deploy_to_environments() { local run_id=$1 shift local environments=("$@")

下载制品

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

部署到每个环境

for env in "${environments[@]}"; do echo "Deploying to: $env"
# 获取环境特定变量
VG_ID=$(az pipelines variable-group list --query "[?name=='$env-vars'].id" -o tsv)

# 运行部署流水线
DEPLOY_RUN_ID=$(az pipelines run \
  --name "Deploy-$env" \
  --variables ARTIFACT_PATH=./artifacts ENV="$env" \
  --query "id" -o tsv)

# 等待部署完成
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 }
undefined

Enhanced Global Arguments

增强的全局参数

ParameterDescription
--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
参数描述
--help
/
-h
显示命令帮助
--output
/
-o
输出格式(json, jsonc, none, table, tsv, yaml, yamlc)
--query
JMESPath查询字符串,用于筛选输出
--verbose
增加日志详细程度
--debug
显示所有调试日志
--only-show-errors
仅显示错误,抑制警告
--subscription
订阅名称或ID
--yes
/
-y
跳过确认提示

Enhanced Common Parameters

增强的通用参数

ParameterDescription
--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)
参数描述
--org
/
--organization
Azure DevOps组织URL(例如:
https://dev.azure.com/{org}
--project
/
-p
项目名称或ID
--detect
从git配置自动检测组织
--yes
/
-y
跳过确认提示
--open
在浏览器中打开资源
--subscription
Azure订阅(用于Azure资源)

Getting Help

获取帮助

bash
undefined
bash
undefined

General help

通用帮助

az devops --help
az devops --help

Help for specific command group

特定命令组的帮助

az pipelines --help az repos pr --help
az pipelines --help az repos pr --help

Help for specific command

特定命令的帮助

az repos pr create --help
az repos pr create --help

Search for examples

搜索示例

az find "az repos pr create"
undefined
az find "az repos pr create"
undefined