Azure DevOps — Complete Setup Guide
CodeScan connects to your Azure DevOps repository using the REST API and a Personal Access Token (PAT). It fetches your source files, runs the full AI security pipeline on them, applies fixes, and opens a Pull Request — all without installing any extension, agent, or marketplace listing. This guide walks through every step from zero to your first fix PR.
Step 1 — Find your organisation, project, and repository names
Every Azure DevOps resource lives under three identifiers. You need all three to connect CodeScan.
dev.azure.com/contoso/backend-services/_git/api-server→ Organisation:
contoso · Project: backend-services · Repository: api-serverStep 2 — Create a Personal Access Token (PAT)
A PAT is a secure alternative to your password. It grants CodeScan exactly the permissions it needs — nothing more.
2a. Open the PAT management page
- Sign in at dev.azure.com
- Click your profile avatar in the top-right corner
- Select Personal access tokens from the dropdown
- You will land on the User settings → Personal Access Tokens page
2b. Create the token
- Click + New Token
- Fill in the form:Namee.g. CodeScan Security ScannerOrganisationSelect the organisation that owns the repo you want to scanExpiration90 days recommended — you can regenerate it later
- Under Scopes, select Custom defined
- Expand the Code section and tick:☑
Code (Read)— Fetch source files from the repository☑Code (Write)— Create branches and commit AI-generated fixes☑Pull Request (Contribute)— Open the fix Pull Request - Click Create
- Copy the token immediately — Azure DevOps shows it only once. Paste it somewhere safe before closing the dialog.
Step 3 — Use the Azure tab in the CodeScan web scanner
3a. Open the Remote Repo panel
- Go to codesscan.com/scan and sign in
- In the left sidebar, click the ⎇ REMOTE REPO tab (next to ⬆ FILES)
- At the top of the panel you will see three provider chips — click Azure
3b. Fill in the fields
| Field | What to enter | Example |
|---|---|---|
| Repo URL or shorthand | org/project/repo, or the full dev.azure.com URL | contoso/backend-services/api-server |
| Personal Access Token | The PAT you copied in Step 2 | pibvykumz6xyz… |
3c. Fetch & Scan
Click ⎇ Fetch & Scan. CodeScan will:
- Authenticate with Azure DevOps using your PAT
- Retrieve the recursive file tree for the default branch (up to 60 source files)
- Fetch each file's content in parallel
- Run the full 5-step AI security pipeline on every file
- Run secret scanning in parallel (looks for hardcoded API keys, tokens, passwords)
- Show results in the CODE FINDINGS, DEPENDENCIES, and SECRETS tabs
The sidebar will confirm the fetch with the repo name, branch, and number of files loaded.
Step 4 — Review and apply fixes
Apply a fix to a single vulnerability
- In the CODE FINDINGS tab, click any file card to open the Detail view
- Click a vulnerability to open its full description
- Click ⚡ Apply AI Fix — the fix is generated and applied to the file in the scanner
- Use the Show diff toggle to see exactly what changed
Use CodescanBot to apply fixes (conversational)
- Open CodescanBot (click ◈ CodescanBot in the header or press Ctrl+K)
- Select a vulnerability from the list
- Click the ⚡ Apply fix chip or type “fix this”
- The bot explains the change and applies it — the file updates automatically
Step 5 — Create the Fix Pull Request
Once one or more files have been patched in the scanner, a green button appears in the sidebar:
- Click ⎇ Create Fix PR
- A modal opens. Confirm or edit:
- Branch name — default:
codescan/security-fixes-YYYYMMDD - PR title — default:
[CodeScan] Security fixes — N file(s) patched
- Branch name — default:
- Click ⎇ Create PR
- CodeScan creates the branch, commits all patches in a single push, and opens the PR
- The PR URL appears in the sidebar — click it to review the diff on Azure DevOps before merging
What the PR looks like in Azure DevOps
- Source branch:
codescan/security-fixes-20260514 - Target branch: your default branch (e.g.
main) - Description lists every patched file with a review checklist
- The Files tab shows the exact diff — only vulnerable lines changed
- Run your pipelines and tests, then complete/approve the PR normally
Step 6 — Using the CLI instead
The CLI gives you the same scan + fix + PR capability from your terminal, perfect for CI/CD automation.
Install & login
npm install -g codescan-flowlog
codescan loginSet your PAT as an environment variable
export AZURE_DEVOPS_TOKEN=your-pat-here
# Now all azure commands use it automaticallyScan a repo (read-only — nothing written to Azure)
# Basic scan of the default branch
codescan azure scan contoso/backend-services/api-server
# Scan a specific branch
codescan azure scan contoso/backend-services/api-server --branch develop
# Show every finding (not just summary)
codescan azure scan contoso/backend-services/api-server --verbose
# Save full JSON report
codescan azure scan contoso/backend-services/api-server --output report.json
# Scan more than 60 files
codescan azure scan contoso/backend-services/api-server --max-files 100Scan + fix + open PR (one command)
# Fix high+ severity and open PR
codescan azure fix contoso/backend-services/api-server
# Preview without writing (dry run)
codescan azure fix contoso/backend-services/api-server --dry-run
# Fix only critical findings
codescan azure fix contoso/backend-services/api-server --severity critical
# Custom branch and PR title
codescan azure fix contoso/backend-services/api-server \
--pr-branch security/q2-patches \
--pr-title "Security: patch SQL injection and XSS — Sprint 42"
# Scan a non-default branch
codescan azure fix contoso/backend-services/api-server --branch stagingRecommended workflow
# 1. Dry run to preview what would change
codescan azure fix org/project/repo --dry-run
# 2. Review the output, then apply
codescan azure fix org/project/repo
# 3. The PR URL is printed — open it and review the diff
# 4. Run tests in Azure Pipelines, then complete the PRCLI flag reference — codescan azure
| Flag | Env var | Default | Description |
|---|---|---|---|
| --token <pat> | AZURE_DEVOPS_TOKEN | — | Azure DevOps PAT (Code Read+Write + PR Contribute) |
| --branch <name> | — | default | Base branch to scan |
| --max-files <n> | — | 60 | Max source files to fetch |
| --severity <level> | — | high | Min severity to fix: critical | high | medium | low |
| --dry-run | — | false | Preview fixes without writing to Azure DevOps |
| --pr-branch <name> | — | auto | Name for the fix branch |
| --pr-title <text> | — | auto | Pull request title |
| -v, --verbose | — | false | Show all per-file findings |
| --output <path> | — | — | Save JSON report to file (scan only) |
| -u, --url <url> | — | codesscan.com | Override CodeScan API base URL |
Azure Pipelines — automated security scanning
Add CodeScan to your Azure Pipeline so every PR is scanned automatically. The job fails if critical vulnerabilities are found, blocking the merge.
# azure-pipelines.yml
trigger:
branches:
include: [main, develop]
pr:
branches:
include: ["*"]
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: "20.x"
- script: npm install -g codescan-flowlog
displayName: Install CodeScan CLI
- script: |
codescan scan --dir ./src \
--gate \
--sarif-out $(Build.ArtifactStagingDirectory)/results.sarif \
--save-history \
--fail-on high
displayName: Run CodeScan Security Scan
env:
CODESCAN_TOKEN: $(CODESCAN_TOKEN)
- task: PublishBuildArtifacts@1
condition: always()
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: codescan-resultsAdd CODESCAN_TOKEN as a Pipeline variable: Project settings → Pipelines → Library → + Variable group → add CODESCAN_TOKEN and mark it as secret.
Troubleshooting
Quick reference cheatsheet
# ── Setup ─────────────────────────────────────────────────────────
export AZURE_DEVOPS_TOKEN=your-pat
# ── Find your repo identifier ──────────────────────────────────────
# URL: dev.azure.com/{org}/{project}/_git/{repo}
# Use: {org}/{project}/{repo} e.g. contoso/backend/api-server
# ── Scan ──────────────────────────────────────────────────────────
codescan azure scan org/project/repo # default branch
codescan azure scan org/project/repo --branch dev # specific branch
codescan azure scan org/project/repo --verbose # all findings
codescan azure scan org/project/repo --output r.json
# ── Fix + PR ──────────────────────────────────────────────────────
codescan azure fix org/project/repo # fix high+ → PR
codescan azure fix org/project/repo --dry-run # preview
codescan azure fix org/project/repo --severity critical
codescan azure fix org/project/repo --pr-branch security/q2-fixes
# ── Web UI ────────────────────────────────────────────────────────
# codesscan.com/scan → ⎇ REMOTE REPO → Azure chip
# Enter: org/project/repo + PAT → Fetch & Scan → Create Fix PR