We will cover the following topics:

  1. Prerequisites
  2. Creating an Azure DevOps Project
  3. Setting up Azure CLI
  4. Creating an Azure Pipeline using the CLI
  5. Running the Pipeline
  6. Conclusion

Prerequisites

Before we begin, please make sure you have the following prerequisites in place:

  1. An Azure account
  2. An Azure DevOps organization and project created
  3. Azure CLI installed and configured

Creating an Azure DevOps Project

To create an Azure DevOps project, follow these steps:

  1. Go to the Azure DevOps website and sign in to your account.
  2. Click on “New Project” and give your project a name.
  3. Select the appropriate settings for your project, such as the version control system you want to use.
  4. Click on “Create Project” to create your project.

Setting up Azure CLI

To set up Azure CLI, follow these steps:

  1. Download and install the Azure CLI from the official Microsoft website.
  2. Open a command prompt or terminal and run the command az login to log in to your Azure account.
  3. Follow the instructions on the screen to complete the login process.

Creating an Azure Pipeline using the CLI

To create an Azure Pipeline using the CLI, follow these steps:

  1. Open a command prompt or terminal and navigate to the directory where you want to create your pipeline.
  2. Run the command az pipelines create to create a new pipeline.
  3. Follow the instructions on the screen to complete the pipeline creation process.
  4. You will be prompted to provide the following information:
    • Project name: The name of your Azure DevOps project.
    • Pipeline name: The name you want to give to your new pipeline.
    • Pipeline description: A brief description of your new pipeline.
    • Repository type: The type of repository you want to use.
    • Repository URL: The URL of the repository you want to use.
    • Branch name: The name of the branch you want to use.
    • YAML file path: The path to the YAML file that defines your pipeline.
  5. Once you have provided all the required information, the CLI will create a new pipeline in your Azure DevOps project.

Running the Pipeline

To run your newly created pipeline, follow these steps:

  1. Open a command prompt or terminal and navigate to the directory where your pipeline YAML file is located.
  2. Run the command az pipelines build queue to queue a new build.
  3. You will be prompted to provide the following information:
    • Project name: The name of your Azure DevOps project.
    • Pipeline ID: The ID of the pipeline you want to run.
  4. Once you have provided all the required information, the CLI will queue a new build for your pipeline.
  5. You can monitor the status of your pipeline build by navigating to the “Pipelines” section of your Azure DevOps project.

Conclusion

In this tutorial, we went through the steps required to create an Azure DevOps Pipeline using the Azure CLI. We covered the prerequisites, creating an Azure DevOps project, setting up Azure CLI, creating an Azure Pipeline using the CLI, and running the Pipeline. By following these steps, you should now be able to create and run pipelines using the Azure CLI.