# Azure DevOps Services and Server

> Connect Azure DevOps Services or Azure DevOps Server to MergeHarbor with Microsoft Entra ID or a personal access token, then choose repositories to review.

MergeHarbor works with **Azure DevOps Services** (dev.azure.com) and **Azure DevOps Server 2020 or later**.

## Azure DevOps Services

Choose **Azure DevOps Services** in the console and select **Connect with Microsoft Entra ID**. You can enter your organization URL (for example `https://dev.azure.com/acme`) to limit the connection to one organization; otherwise MergeHarbor can use every organization you belong to. Your organization must allow third-party application access via OAuth (**Organization settings → Policies**).

You can also connect with a personal access token instead.

### If the connection fails

When Microsoft signs you in but Azure DevOps can't use that account, MergeHarbor returns you to the page you started from and says why:

- **This Microsoft account has no Azure DevOps profile.** The account has never opened Azure DevOps, or it's a different account or tenant from the one your organization uses. Open [dev.azure.com](https://dev.azure.com) once with that account, or choose **Try again with another account** and pick the account your organization uses.
- **We couldn't find an Azure DevOps organization for this account.** Choose **Enter your organization** and type the name after `dev.azure.com/` (or paste the organization's URL). The connection is then limited to that organization.
- **This Microsoft account can't open the organization.** Sign in with an account that's a member of the organization, or ask one of its admins to add your account.

Admins can see Azure DevOps' own answer in **Settings → Audit log** (the `onboarding.*` event's details).

## Azure DevOps Server

Choose **Azure DevOps Server**, enter your **collection URL** (for example `https://tfs.example.com/tfs/DefaultCollection`), and paste a personal access token. Servers on a private network must be reachable from MergeHarbor; with self-hosted MergeHarbor, your operator allows private addresses.

## Personal access tokens

Create the token for a service account with these scopes: **Code (Read & write)**, **Code (Status)**, **Service Hooks (Read & write)**, and **Project and Team (Read)**. The account needs permission to contribute to pull requests and to edit service hook subscriptions in each project; project administrators have both.

## What MergeHarbor does

- Registers service hooks for the repositories you enable (pull request created and updated, pull request comments, and pushes).
- Posts findings as pull request threads on the changed lines, plus a summary.
- Reports a pull request status named `mergeharbor/review`. Add it to a branch policy under **Status checks** to require a passing review before completion.
- Learns from your feedback: liking a MergeHarbor comment, or resolving its thread as **Fixed** or **Won't fix**.
- Replies to `@mergeharbor` mentions and runs [commands](https://mergeharbor.com/docs/configuration#commands-in-pull-requests) in pull request comments. A comment that starts with `mergeharbor review` (no `@`) is a command too.
- Keeps one set of service hooks per repository: registering a repository again, for example after you reconnect, removes the subscriptions MergeHarbor created before. If the same comment still arrives more than once, it is acted on once.

## Reconnect, switch accounts or disconnect

- **Reconnect** (Integrations → Code hosts) replaces the token of the account the connection belongs to, for example after a token expired or was revoked. Signing in as a different Azure DevOps account is refused and nothing changes. After a reconnect, MergeHarbor registers the webhooks of the enabled repositories again with the new credentials; a repository the account can no longer access stops being reviewed and shows a webhook error on the Repositories page.
- **Switch accounts** by disconnecting and connecting the other account.
- **Disconnect** stops reviews at once and removes MergeHarbor's webhooks from Azure DevOps. The repositories' reviews, index and settings are kept for 7 days, then permanently deleted. Connecting Azure DevOps again within those 7 days brings the repositories back with their history; the ones that were enabled are reviewed again if the connected account can see them, and the others stay disabled.
- A repository belongs to one MergeHarbor organization at a time. Enabling a repository that another organization has connected is refused until it is disconnected there.
