# Configuring Azure DevOps project binding

Once your Azure DevOps organization has been imported to SonarQube Cloud, you can create and set up your project by importing your Azure DevOps repository. The created SonarQube Cloud project is bound to its Azure DevOps repository, see [binding-with-dop](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/administering-sonarcloud/about-sonarqube-cloud-solution/resources-structure/binding-with-dop "mention") for more details. To bind an unbound project, see [#binding-an-unbound-project-to-a-repository](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/managing-your-projects/changing-binding#binding-an-unbound-project-to-a-repository "mention").

## Setting up pull request integration with Azure DevOps

With a bound project, SonarQube Cloud can:

* Report the quality gate status and analysis metrics to your pull requests in Azure DevOps.
* Show issues detected on a pull request in Azure DevOps. Each issue will be a comment on the Azure DevOps pull request. If you change the status of an issue in SonarQube Cloud, that status change is immediately reflected in the Azure DevOps interface.

{% hint style="info" %}
The number of comments posted in the timeline of a pull request is limited to 50.

If this limit has been reached, a message will be displayed as a comment, with a link to the rest of the issues on SonarQube Cloud. This comment will not disappear upon resolution of an issue, but only upon a new build, with less than 50 issues remaining.
{% endhint %}

To set up the pull request analysis:

1. See [#prerequisites-for-ci-based-analysis](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/analyzing-source-code/pull-request-analysis#prerequisites-for-ci-based-analysis "mention") for more information.
2. Enable the pull request analysis on the target branch: see below.
3. If you don't use an integrated CI tool like Azure Pipelines, you must set up the pull request parameters manually. See [#pull-request-analysis](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/analyzing-source-code/analysis-parameters#pull-request-analysis "mention") for more details.
4. You can prevent the pull request merge if the quality gate fails: see below.

<details>

<summary>Enabling pull request analysis on target branch for unbound projects only</summary>

{% hint style="warning" %}
If you have a bound project, stop. Do not follow the instructions below because you already have an Azure Personal Access Token (PAT) assigned at the organization level. To update the organization PAT on a bound project, see these instructions: [#change-pat](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/administering-sonarcloud/managing-organization/creating-organization/changing-organization-settings#change-pat "mention")
{% endhint %}

If you created a project manually without linking to an Azure DevOps repository (known as an *unbound project*), you can set the Azure PAT at the project level by following these steps.

1. On the **Branch policies** page of your target branch, add a [build validation policy](https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git#pr-triggers).
2. Create an Azure DevOps Personal Access Token having a **Code (read and write)** scope.
3. In SonarQube Cloud, set this token by navigating to *Your Project* > **Administration** > **General Settings** > **Pull Requests** > **Integration with Azure DevOps Services**.

</details>

<details>

<summary>Preventing pull request merges when the quality gate fails</summary>

To prevent the merge of pull requests when the quality gate fails, proceed as follows (you can also watch this [video](https://www.youtube.com/watch?v=be5aw9_7bBU) for a quick overview of the procedure):

1. Go to the **Branch policies** page of your main branch.
2. Under **Require approval from additional services**, select **Add status policy**.
3. In the **Status to check** dropdown, select **SonarQube/quality gate**.
4. Then choose the option depending on your need:
   * **Optional:** Users will be able to merge a pull request even if the quality gate fails.
   * **Required:** Users will not be able to merge a pull request unless the quality gate passes.
5. Select **Save**.

{% hint style="info" %}
This feature is not supported for projects on a monorepo.
{% endhint %}

</details>

## Related pages <a href="#related-pages" id="related-pages"></a>

* [azure-devops](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/getting-started/azure-devops "mention")
* [importing-azure-devops-organization](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/administering-sonarcloud/managing-organization/creating-organization/importing-azure-devops-organization "mention")
* [setting-up-project](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/managing-your-projects/administering-your-projects/setting-up-project "mention")
* [setting-permissions](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/managing-your-projects/administering-your-projects/setting-permissions "mention")
* [changing-binding](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/managing-your-projects/administering-your-projects/changing-binding "mention")
* [customizing-info-page](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/managing-your-projects/administering-your-projects/customizing-info-page "mention")
* [deleting-project](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/managing-your-projects/administering-your-projects/deleting-project "mention")
* [in-devops-platform](https://docs.sonarsource.com/sonarqube-cloud/~/changes/1027/managing-your-projects/issues/in-devops-platform "mention")
