Post

Create Work Items in Azure DevOps project using Az CLI

To create work items in Azure DevOps we need to have an Azure DevOps organization and project. If you don’t have either of these, please follow steps in Onboarding to Azure DevOps and Getting Started with Azure DevOps using Az CLI to onboard Azure DevOps and install Azure DevOps (ADO) extension to Az CLI.

Create work item

The command to run is az boards work-item create to create work items. The complete syntax of command is shown below:

1
2
3
4
5
6
7
8
9
10
11
12
13
az boards work-item create --title
                           --type
                           [--area]
                           [--assigned-to]
                           [--description]
                           [--detect {false, true}]
                           [--discussion]
                           [--fields]
                           [--iteration]
                           [--open]
                           [--org]
                           [--project]
                           [--reason]

Here is the complete command to run using PowerShell to create a work item. I am trying to create an Epic work item type here:

1
2
3
4
5
6
7
8
$organization = "https://dev.azure.com/datosmic/"
$project = "datosmic-project1"

az boards work-item create `
    --title "Epic1" `
    --type "Epic" `
    --org $organization `
    --project $project

If you want to create a Task type, you can replace --type "Epic" with --type "Task" in the above command.

The backtick “`” used in the command is just to let shell know the continuation of the command in different/multiple lines for better readibility purpose. The above same command can be also written/executed as below:

1
2
3
4
$organization = "https://dev.azure.com/datosmic/"
$project = "datosmic-project1"

az boards work-item create --title "Epic1" --type "Epic" --org $organization --project $project`

Once the command has successfully ran, we would see an JSON output of complete work item details. We can see the Work Item CreatedDate, ID, State, Type, Title, Project etc.. from the JSON output.

ADO-WI-Creation

We can navigate to Azure DevOps portal to see the work item created.

ADO-WI

ADO-WI2

See Also

This post is licensed under CC BY 4.0 by the author.