> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/autofix-and-remediation/configure/autofix-for-azure-devops-with-entra-service-principal.md).

# AutoFix for Azure DevOps with an Entra Service Principal

> Instead of a Personal Access Token or the OAuth flow, you can let Aikido Autofix authenticate to Azure DevOps as a Microsoft Entra service principal that you own. No token or secret is created or stored: for every fix, Aikido proves its identity to Microsoft Entra, which issues a short-lived access token for your service principal.

> Please note that your Azure DevOps organization must be connected to a Microsoft Entra tenant ('**Organization settings**' > '**Microsoft Entra**'). You need to be able to register applications in that tenant and to add users to your Azure DevOps organization.

**First**, go to the [Autofix Settings](https://app.aikido.dev/settings/integrations/autofix) page in Aikido, click '**Authorize**' under **Write Access** and choose '**Authorize via Entra service principal**'.

![Authorize via Entra service principal option in the Aikido Autofix settings](https://3149773201-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-d1d899c85693807db6d44bf9007bde1094f16bde%2Fentra-sp-auth-method-in-aikido.png?alt=media)

You end up on the service principal management page, which can also be [found here](https://app.aikido.dev/settings/integrations/azure-devops/autofix/service-principal). Keep this page open: it shows the **Issuer**, **Subject identifier** and **Audience** you need in the next section.

![Issuer, Subject identifier and Audience values on the Aikido service principal page](https://3149773201-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-1d62bf6de399811eb4dc1b6f4b49a44aa70836ae%2Fentra-sp-values-in-aikido.png?alt=media)

**Next**, follow the instructions below to create the service principal in Microsoft Entra and give it access in Azure DevOps.

## Registering the application in Microsoft Entra <a href="#registering-the-application-in-microsoft-entra" id="registering-the-application-in-microsoft-entra"></a>

1. Open the [Microsoft Entra admin center](https://entra.microsoft.com), navigate to '**Entra ID**' > '**App registrations**' and click '**New registration**'.
2. Give the application a name, for example **Aikido Autofix**, keep '**Single tenant only**' selected, leave the Redirect URI empty and click '**Register**'.

   ![Registering a new application in Microsoft Entra](https://3149773201-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-043b18018525692ce1438174b125b4c36e1e1bf2%2Fentra-sp-register-app-in-entra.png?alt=media)
3. On the '**Overview**' page of the application, copy the **Application (client) ID** and the **Directory (tenant) ID**. Insert both in Aikido.
4. Navigate to '**Certificates & secrets**' > '**Federated credentials**' and click '**Add credential**'.

   ![Federated credentials tab in the Entra app registration](https://3149773201-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-07b64526e8b6664512278fce679040a00b9d859f%2Fentra-sp-federated-creds.png?alt=media)
5. Select '**Other issuer**' and fill in the values exactly as shown on the service principal management page in Aikido:

   * **Issuer**: the Issuer shown in Aikido
   * **Type**: Explicit subject identifier
   * **Value**: the Subject identifier shown in Aikido
   * **Audience**: click '**Edit**' and replace the default with the Audience shown in Aikido. It contains your workspace id, so only tokens Aikido mints for your workspace are accepted.

   Give the credential a name, for example **autofix**, and click '**Add**'. You do not need a client secret or certificate.

   ![Federated credential form filled in with the values from Aikido](https://3149773201-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-d309798c6578f86ef3774d454465c1ba9377a241%2Fentra-sp-values.png?alt=media)

## Granting access in Azure DevOps <a href="#granting-access-in-azure-devops" id="granting-access-in-azure-devops"></a>

1. In Azure DevOps, navigate to '**Organization settings**' > '**Users**' and click '**Add users**'.
2. Search for the application name (**Aikido Autofix**), set the '**Access level**' to **Basic**, and add it to the projects Autofix needs access to. Then click '**Add**'. If the application does not show up yet, wait a minute and search again.

   ![Adding the service principal as a user in Azure DevOps](https://3149773201-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyKbzcQGrx7UtrG0nPZZ7%2Fuploads%2Fgit-blob-29005d221afc15201269dc4ea4c00cb55229b405%2Fentra-sp-add-it-as-user.png?alt=media)

> Adding the service principal to a project puts it in that project's **Contributors** group, which already grants the permissions Autofix needs. If your organization restricts Contributors on repositories, allow **Contribute**, **Create branch** and **Contribute to pull requests** for **Aikido Autofix** under each project's '**Project settings**' > '**Repositories**' > '**Security**'.

## Connecting in Aikido <a href="#connecting-in-aikido" id="connecting-in-aikido"></a>

1. Go back to the service principal management page in Aikido.
2. Insert the **Directory (tenant) ID** and the **Application (client) ID** you copied earlier and click '**Save Service Principal**'. Aikido requests a token from Microsoft Entra and verifies that it can access the repositories of your Azure DevOps organization before saving.

You are all set. You will now be able to execute autofix PRs from the [Autofix page](https://app.aikido.dev/issues/fix) or from the action menu for subissues in the sidebar. Pull requests are created by **Aikido Autofix**.

> To revoke Aikido's write access, delete the federated credential in Microsoft Entra or remove the service principal from your Azure DevOps organization. To remove the configuration in Aikido, use '**Remove token**' on the [Autofix Settings](https://app.aikido.dev/settings/integrations/autofix) page.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.aikido.dev/autofix-and-remediation/configure/autofix-for-azure-devops-with-entra-service-principal.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
