A previous article guided you through setting up your repository. You did this by creating multiple branches that reflect the GitFlow model and protecting those branch use policies. Then, I gave you an overview of how pull requests work. This article - the final installment in the Azure series - will show you how to implement Azure’s continuous testing, integration, and deployment mechanisms.

Continuous Integration
Continuous Integration (CI) is a practice that allows multiple developers to frequently merge code changes into a remote repository by automating the build, test, and run processes. To implement your own CI pipeline in Azure, follow these steps:
- From the dashboard, select Pipelines.
- Click the New Pipeline button.
- Select Azure Git Repos as a source that will trigger our pipeline.
- From the multiple templates that Azure DevOps will suggest, select Starter Pipeline and paste the following code in it.
trigger: - mainpool: vmImage: ubuntu-latestvariables: buildConfiguration: 'Release'steps: - script: dotnet build --configuration $(buildConfiguration) displayName: 'dotnet build $(buildConfiguration)'- task: PublishBuildArtifacts@1 inputs: PathtoPublish: '$(Build.ArtifactStagingDirectory)' ArtifactName: 'drop' publishLocation: 'Container'
Continuous Testing
As mentioned before, the continuous integration pipeline can perform both static and dynamic tests automatically. Static testing is a technique to improve the quality of your application by detecting bugs, vulnerabilities, and code smells without executing your application’s code. Dynamic testing, on the other hand, focuses on the behavior of your application; it requires the execution of your application’s code.
This tutorial will teach you how to perform static testing using SonarCloud.
Install the SonarCube Extension
To be able to use the SonarCloud functionalities, you must install the SonarCloud extension in your organization using the following steps:
- Sign in to your Azure DevOps organization.
- Go to Organization Settings.
- Select Extensions.
- Click on Browse Marketplace at the top right.

- As the Marketplace opens, search for SonarCloud. Click on the correct SonarCloud result as shown below,

- Click on the Get it Free button.
- Select your target organization from the dropdown, then click Install to complete the procedure.
Link the Project to SonarCloud
It is now time to connect your Azure DevOps project to SonarCloud.
- Navigate to https://sonarcloud.io/ in your browser, then click login at the top of the page.
- Select With Azure DevOps and grant permissions to SonarCloud.

- Click on your profile’s icons on the top right side of the window, then select My Account.
- Enter the name of your token, click the Generate button, and copy the token.

- From your Azure DevOps organization, navigate to your project.
- From the Project Settings, open the Service Connections Page.
- Click the New Service Connection button and select SonarCloud to define and secure a connection to a SonarCloud.

Fill in the parameters for the service connection, allowing all pipelines to use this connection option.

Click Verify and Save to create the connection.
Create a New Project on SonarCloud
Before you continue with the configuration of the CI pipeline, you must create a project on SonarCloud that will be linked to the repository in the next steps.
- Sign in to your SonarCloud account.
- Select the My Projects tab on the top left side of the page.
- Click the Analyze New Project button.

Select your organization, check your project and click Set Up.

Add Task into the Continuous Integration Pipeline
Now that you have successfully connected your SonarCloud account to your project, you can move forward and add the SonarCloud-specific tasks installed by the extension into your continuous integration pipeline.
- From the dashboard, select Pipelines.
- Select the pipeline that you previously created.
- Click the Edit button on the top right-hand corner of the page.
- Filter the available tasks for SonarCloud.

The order in which these tasks should be executed is,
- Prepare Analysis Configuration: configures the settings before executing the build
- Run Code Analysis: analyzes the source code
- Publish Quality Gate Result (optional): shows if the code meets the quality standards in the build summary
Let us start by adding a Prepare Analysis Configuration task before the build task. Here you must select the service connection, the organization, how the analysis is done (MSBuild in this tutorial because the example application was developed using the .NET 5 framework), the project key, and the project name.

The project key is the values of the parameter ID in the URL of your SonarCloud project.

- Add a new Run Code Analysis task after your build task.
- Add a new Publish Quality Gate Result task on your build pipeline summary.
- Add a new .NET Core task with the command Publish. Make sure the Zip Published Project option is checked.

Lastly, add the Publish Build Artifact task.



















Join the conversation! Your thoughts help the community grow.