> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.knapsack.cloud/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.knapsack.cloud/_mcp/server.

# Azure Dev Ops

## Overview

By integrating Knapsack with Azure DevOps, you can streamline your design and development workflows, automate testing and deployment processes, and maintain a high level of code quality. Azure DevOps' seamless integration with other Azure services also provides a cohesive environment for managing your entire development lifecycle.

### Cloud Authoring

#### Authentication through Personal Access Token (PAT)

To enable cloud authoring within Azure, we use a Personal Access Token (PAT) for authentication. This token allows secure access to your Azure repositories and enables necessary actions on your behalf.

### Step 1: Add Knapsack Bot

Add our Knapsack Bot ([knapsack-bot@knapsack.cloud](mailto:knapsack-bot@knapsack.cloud)) to your repository as a collaborator with the necessary permissions.

#### Permissions Required

You may need administrative privileges on your repository to invite the Knapsack Bot as a collaborator. If you encounter any issues, please reach out to our support team for assistance.

### Step 2: Token Generation

With Knapsack Bot added, we will take care of generating the token for you.

#### Important Notes

This is a manual process. If handling asynchronously, we'll notify you when it is completed.

#### Mandatory Step

This step must be completed for Cloud Authoring to function.

### Alternative Configuration

#### Generate and Securely Deliver a Token

**Follow the below steps if your organization would prefer to completely own the PAT:**

1. Your organization handles generating a PAT.
2. Securely deliver the token to us. We can arrange a live session to ensure secure delivery and setup.

***

## Web Hooks

### **Integrating Repository Events with the Knapsack API**

To synchronize repository-related events with the Knapsack UI, it's crucial to set up web hooks. Specifically, we'll configure two web hook triggers:

1. **"Pull request merge attempted"**
2. **"Pull request updated"**

This setup will automatically update the Knapsack UI when pull requests (PRs) are closed in Azure, such as removing a branch from the active branch list.

#### **Steps to add the first web hook:**

1. Follow the guidelines in [this article](https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops) to get started.
2. Navigate to **"Service Hooks"** under **"Project Settings"** (found in the bottom left corner).
3. Click the **"Add New"** icon, then select **"Web Hook"**. Proceed by clicking "Next."
4. For the trigger, choose **"Pull request merge attempted"**.
5. Ensure the appropriate repository is selected. Leave all other options set to **"\[Any]"**.
6. Click "Next."
7. In the settings section, input the following URL: [https://api.knapsack.cloud/webhooks/azure](https://api.knapsack.cloud/webhooks/azure).
8. Conclude by clicking **"Finish"**.

#### Steps to add the second web hook:

1. Repeat steps above with trigger set to **"Pull request updated"**
2. All other settings should match the previous above steps

![file-tsLRTt1fQN.png](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/knapsack-docs.docs.buildwithfern.com/302a86a7c757ea48ddaefd2113c82f1fb1792221d6e1d67128ca06c072593833/docs/assets/images/0916d325-file-tslrtt1fqn-tfl24ngi9ppng.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260724%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260724T211226Z&X-Amz-Expires=604800&X-Amz-Signature=b833e7bf531e8b3d482c9b46fa93fd82c3fc5de7f3c0adaec89f29f8b80b1bd8&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)
![file-GbR3De3U0N.png](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/knapsack-docs.docs.buildwithfern.com/0d431dcf0198ed6c0656081a36b33745fd73be1c772d44c1d9192e00c4759e2b/docs/assets/images/1c709bf3-file-gbr3de3u0n-uyfksuzj8tpng.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260724%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260724T211226Z&X-Amz-Expires=604800&X-Amz-Signature=4c21e55c2ec351224ccd3034cb8072637098f00561288461d505a6a0dfb3b899&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

***

## Azure Pipelines

### Required Secret Variables

Deployments to Heroku rely on the following secret variables:

1. `HEROKU_EMAIL` — The email associated with the Heroku account.
2. `HEROKU_API_KEY` — The API Key associated with the Heroku account (found in [profile settings](https://dashboard.heroku.com/account))
3. `HEROKU_GIT_URL` — Located on the app dashboard within Heroku's admin interface

```yaml
trigger:
- main

pool:
  vmImage: ubuntu-latest

variables:
- group: Heroku

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '16.x'
  displayName: 'Install Node.js'
- checkout: self
  fetchDepth: 1
  displayName: 'Checkout source code'
  persistCredentials: true
- script: |
    git fetch --all --unshallow
    git checkout main
    git pull
- script: yarn install
  displayName: 'yarn install'
- script: yarn build
  displayName: 'yarn build'
- script: yarn test
  displayName: 'Knapsack Test'
- script: |
    echo "machine git.heroku.com
      login $(HEROKU_EMAIL)
      password $(HEROKU_API_KEY)" > ~/.netrc
  displayName: 'Write authentication credentials'
- script: git status
- script: |
    git remote add heroku $(HEROKU_GIT_URL)
    git push heroku main
  displayName: 'Git push to Heroku for deploy'
```

### Summary

* The pipeline is triggered by changes to the `main` branch.
* It uses an Ubuntu VM image and defines a variable group for Heroku credentials.
* It installs Node.js, checks out the source code, and fetches the complete Git history.
* It installs dependencies, builds the application, runs tests, and writes Heroku authentication credentials.
* Finally, it pushes the `main` branch to Heroku for deployment.

This setup ensures that changes to the `main` branch are automatically built, tested, and deployed to Heroku.