Azure DevOps is a cloud-based service that offers a complete set of services for managing the software development process. This includes agile planning, source control, build and release management, testing, and DevOps analytics. In this tutorial, we will cover the basics of Azure DevOps and how to use it with CLI commands.

Prerequisites

Before we begin, you will need the following:

  • An Azure DevOps account
  • A command-line interface (CLI) such as PowerShell or Bash
  • Azure CLI installed on your system (version 2.0 or higher)
  • Git installed on your system (version 2.14 or higher)

Step 1: Create a Project

The first step is to create a project in Azure DevOps. To do this, follow these steps:

  1. Open a web browser and navigate to the Azure DevOps portal.
  2. Click on the “Create project” button in the top-right corner.
  3. Enter a name for your project and select a version control system (Git or Team Foundation Version Control).
  4. Click “Create” to create your project.

Step 2: Connect to Azure DevOps with CLI

The next step is to connect to your Azure DevOps account using the CLI. To do this, follow these steps:

  1. Open the command-line interface (PowerShell or Bash).
  2. Run the following command to log in to your Azure account: az login
  3. Once you have logged in, run the following command to set your default subscription:
az account set --subscription <subscription name>
  1. Finally, run the following command to connect to your Azure DevOps account:
az devops login

Step 3: Create a Repository

Now that you have connected to your Azure DevOps account, you can create a repository for your project. To do this, follow these steps:

  1. Navigate to your project in the Azure DevOps portal.
  2. Click on the “Repos” tab.
  3. Click on the “New repository” button.
  4. Enter a name for your repository and click “Create”.

Step 4: Clone the Repository

Next, you need to clone your repository to your local machine. To do this, follow these steps:

  1. Open the command-line interface.
  2. Navigate to the directory where you want to clone the repository.
  3. Run the following command to clone the repository:
git clone https://<your-repo-url>.git

Step 5: Create a New Branch

It is recommended that you create a new branch for each new feature or bug fix that you are working on. To create a new branch, follow these steps:

  1. Open the command-line interface.
  2. Navigate to the repository directory.
  3. Run the following command to create a new branch:
git checkout -b <new-branch-name>

Step 6: Add and Commit Changes

Now that you have created a new branch, you can make changes to your code. To add and commit your changes, follow these steps:

  1. Open the command-line interface.
  2. Navigate to the repository directory.
  3. Make changes to your code.
  4. Run the following command to add your changes:
git add .
  1. Run the following command to commit your changes:
git commit -m "commit message"

Step 7: Push Changes to Azure DevOps

After committing your changes, you need to push them to Azure DevOps. To do this, follow these steps:

  1. Open the command-line interface.
  2. Navigate to the repository directory.
  3. Run the following command to push your changes:
git push origin <new-branch-name>

Step 8: Create a Pull Request

Once you have pushed your changes to Azure DevOps, you can create a pull request to merge your changes into the main branch. To create a pull request, follow these steps:

  1. Navigate to your project in the Azure DevOps portal.
  2. Click on the “Repos” tab.
  3. Click on your branch name.
  4. Click on the “New pull request” button.
  5. Enter a title and description for your pull request.
  6. Review your changes and click “Create”.

Step 9: Approve and Merge the Pull Request

After creating the pull request, you need to wait for a reviewer to approve your changes. Once your changes have been approved, you can merge your changes into the main branch. To approve and merge the pull request, follow these steps:

  1. Navigate to your project in the Azure DevOps portal.
  2. Click on the “Pull requests” tab.
  3. Click on your pull request.
  4. Review your changes and click “Approve”.
  5. Click on “Complete” and select “Merge”.
  6. Enter a merge commit message and click “Complete”.

Step 10: Deploy Changes

Finally, you can deploy your changes to your production environment. To do this, follow these steps:

  1. Navigate to your project in the Azure DevOps portal.
  2. Click on the “Pipelines” tab.
  3. Click on the “New pipeline” button.
  4. Select your repository and branch.
  5. Choose a deployment template and configure your deployment settings.
  6. Click “Save and run” to deploy your changes.

Conclusion

In this tutorial, we covered the basics of Azure DevOps and how to use it with CLI commands. By following these steps, you can create a new project, connect to Azure DevOps, create a repository, clone the repository, create a new branch, add and commit changes, push changes to Azure DevOps, create a pull request, approve and merge the pull request, and deploy changes to your production environment. With Azure DevOps, you can streamline your software development process and achieve greater productivity and efficiency.