Azure DevOps CLI – Control Azure DevOps in Command Line
Do you want to interact with Azure DevOps using a command line, or automate a task to run to carry out Azure DevOps tasks?
Azure DevOps has a Command Line Interface; this enables you not to worry about calling the Azure DevOps REST Web Services.
How to Get Started?
First things first, you need to install Azure Cloud Shell. Depending on which operating system you are using, there are different instructions. The following link https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest will give you the instructions for your operating system. Below are the commands for Windows Powershell.
|
|
Next step is to install the extension for Azure DevOps.
|
|
List the extensions that are installed.
|
|
Now if you are always working on the same Project / Organisation it is best to set some defaults. You don’t have to set both Organisation or Project’
|
|
Next step is to login you have two approaches
Login to Azure
|
|
Your default browser will open and you will have to login with you Azure DevOps credentials.
Use the PAT code
If you don’t have a PAT code already you will need to create one follow the following steps. In your Azure DevOps organisation you want to access. Click on the profile icon highlighted below with (1) on the top right of the browser. Then click on Personal Access Tokens menu item.
On the Personal Access Tokens screen click on the New Token as highlighted below.
Now What?
So now with Azure DevOps CLI installed you can manage your Azure DevOps Organisations
Command | Description |
---|---|
az devops | Manage Organisation Level |
az pipeline | Manage Azure DevOps Pipelines |
az boards | Manage Azure DevOps Boards |
az repos | Manage Azure DevOps Repositories |
az artifacts | Manage Azure DevOps Artifacts |
az devops project | Manage Azure DevOps Projects |
az develop security | Manage Azure DevOps Security |
az devops teams | Manage Azure DevOps Teams |
az devops user | Manage Azure DevOps Users |
az devops wiki | Manage Azure DevOps Wikis |
az devops extensions | Manage Azure DevOps Extensions |
Please note at the time of writing you can’t use the Azure DevOps tools against a Public project when you aren’t a member of that project.
You can now automate creating your next azure devops project. If you need to create a script and don’t want to be prompted for PAT code there are two options.
- Use a environment variable – $env:AZURE_DEVOPS_EXT_PAT = ‘xxxxxxx’
- Get the PAT code from a file cat my_pat_token.txt | az devops login –organization https://dev.azure.com/azure-devops-tips