Creating Sprints in Azure DevOps Boards using Azure CLI on macOS and Linux

One small operational niggle I’ve found when working with Azure Boards is that I have to create all my sprints one by one.  This can be quite tedious if you’ve got a lot of sprints to add (think one week sprints for a year-long project and you’ll see what I mean). 

Being someone who’s not too keen to waste time clicking when I can get some code to do it for me, I came up with this short shell script that uses the Azure CLI to create them for me. I’m doing this on a Mac but it should work for Linux as well. I’m using version 2.8.0 of the Azure CLI on macOS and you’ll need to install the Azure DevOps extension for Azure CLI; you can do this by running the following command on a machine with the Azure CLI installed:

az extension add --name azure-devops

I’ve used a CSV file to define each sprint, including its name, start date and finish date. If you have a lot of sprints to add, then Microsoft Excel’s fill handle will be your best friend. I’ve not included a header row in the CSV file to keep the complexity low. Note that none of these fields has double quotation marks on either side.

Sprint 11,2020-07-06,2020-07-12
Sprint 12,2020-07-13,2020-07-19

The shell script is fairly straight-forward. It loops through each record in the CSV file, prints it to the console, then uses the az boards syntax to add an interaction to the project. I’ve set it to use verbose output with the —verbose switch. The command requires you to supply the organisation URL and project name as you’d expect. Note that I’ve surrounded the name argument with double quotation marks here because it won’t handle spaces in the sprint name otherwise. 

while IFS=, read -r Name StartDate FinishDate
echo “$Name | $StartDate | $FinishDate"
az boards iteration project create --organization "<organisation name>/" --project “<project name>" --name "$Name" --start-date $StartDate --finish-date $FinishDate --verbose
done < AddSprints.csv

So here’s what my sprints looked like before I ran the script:

Here’s the expected output from the script after running it:

DevMac:azuredevops kris$ ./ 
Sprint 11 | 2020-07-06 | 2020-07-12
Command group 'boards iteration' is in preview. It may be changed/removed in a future release.
  "attributes": {
    "finishDate": "2020-07-12T00:00:00Z",
    "startDate": "2020-07-06T00:00:00Z"
  "children": null,
  "hasChildren": false,
  "id": 80,
  "identifier": "",
  "name": "Sprint 11",
  "path": "\\DeconstructedTechBasic\\Iteration\\Sprint 11",
  "structureType": "iteration",
  "url": "<Snipped>/<Snipped>/_apis/wit/classificationNodes/Iterations/%EF%BB%BFSprint%2011"
Command ran in 3.161 seconds (init: 0.219, invoke: 2.942)
Sprint 12 | 2020-07-13 | 2020-07-19
Command group 'boards iteration' is in preview. It may be changed/removed in a future release.
  "attributes": {
    "finishDate": "2020-07-19T00:00:00Z",
    "startDate": "2020-07-13T00:00:00Z"
  "children": null,
  "hasChildren": false,
  "id": 81,
  "identifier": "<Snipped>",
  "name": "Sprint 12",
  "path": "\\DeconstructedTechBasic\\Iteration\\Sprint 12",
  "structureType": "iteration",
  "url": "<Snipped>/<Snipped>/_apis/wit/classificationNodes/Iterations/Sprint%2012"
Command ran in 1.666 seconds (init: 0.046, invoke: 1.619)

Here’s the results after I ran the script:

For more information on the Azure DevOps extension for Azure CLI, check out this page:

If you’ve found this useful, then make sure to follow my blog by entering your email address in the “Follow Blog Via Email” box or in the Follow widgit or drop me some constructive feedback in the comments box. Thanks.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s