Skip to main content

Step 3: Connect Source Code

10 min · Connect your GitHub repository. Your agent can now perform root cause analysis—correlating production issues to specific code.

What you'll accomplish

By the end of this step, your agent will:

  • Analyze source code during investigations
  • Provide file:line references for issues
  • Create To-Do Plans showing investigation steps
  • Correlate production symptoms to code changes

Prerequisites

RequirementDetails
Agent createdComplete Step 1 first
GitHub PATPersonal Access Token with repo scope

Choose your approach

There are three ways to connect source code:

ApproachBest for
Option A: Resource mappingSingle repo linked to a specific Azure resource
Option B: MCP + subagentAccess to all your GitHub repos
Option C: ADO Documentation connectorAzure DevOps repos and wikis as knowledge sources
tip

Pick whichever approach matches your setup. You can use multiple options together.

For Option C, see the ADO Wiki Knowledge capability page and Connect ADO Wiki tutorial.


Option A: Resource mapping

Associate a repository with an Azure resource. When investigating that resource, your agent automatically references the linked code.

Step 1: Open resource mapping

  1. Click Monitor in the left sidebar.
  2. Select Resource mapping.
  3. Find your resource in the list.
  4. Click the resource to open its detail view.

Step 2: Add repository

  1. Click Add repository.
  2. Paste your GitHub repository URL (e.g., https://github.com/your-org/your-repo).
  3. Sign in to GitHub if prompted.
  4. Click Add.

The repository is now linked to that Azure resource.

Verify it works

Ask your agent about the linked resource:

What could cause memory issues in the grocery-store-api container app?

You should see:

  1. Agent creates a To-Do Plan for the investigation
  2. Loads the source_code_analysis skill
  3. Searches through your linked repository
  4. Returns findings with specific file:line references

Agent To-Do Plan for code investigation

Agent analyzing source code


Option B: MCP + subagent (Advanced)

Connect GitHub as an MCP server for full access to GitHub features. This requires creating a subagent to use the MCP tools.

Step 1: Add GitHub connector

  1. Click Builder in the left sidebar.
  2. Select Connectors.
  3. Click Add connector.

Connectors list

  1. Select GitHub MCP server.
  2. Configure the connection:
FieldValue
Namemy-github (or descriptive name)
Connection typeStreamable-HTTP (default)
URLhttps://api.githubcopilot.com/mcp/
Authentication methodBearer token
Personal access tokenYour GitHub PAT with repo scope
  1. Click Next → Add connector.
  2. Wait for status to show Connected.

GitHub connector connected

Step 2: Create a subagent

MCP tools are not available on the main agent—you need to create a subagent.

  1. Click Builder → Subagent builder.
  2. Click Create subagent.
  3. Configure the subagent:
FieldValue
Namegithub-analyst
DescriptionAnalyzes GitHub repositories for root cause analysis
InstructionsYou analyze source code to find root causes of production issues. When given a repository and symptoms, search for relevant code and provide file:line references.
  1. In the Tools section, select the GitHub MCP tools you need (e.g., search_code, get_file_contents, list_commits).
  2. Click Save.

Verify it works

Ask your agent to hand off to your new subagent:

Use the github-analyst subagent to analyze the code in my-org/my-repo for memory leaks.

The main agent will hand off to your subagent, which uses the GitHub MCP tools to analyze the code.


The difference

Without source code:

"The container app is experiencing memory pressure. Consider increasing memory limits."

With source code:

"Found potential memory leak in src/api/suppliers.js:

Line 45-52: The fetchSupplierData() function creates new HTTP clients per request without cleanup.

Line 110-117: Rate limiting is set to 5 req/min, but the API shows burst patterns of ~40/min.

Recommendation: Add connection pooling or implement client reuse."

Your agent correlates production symptoms to exact code locations.


What repositories to connect

Repository TypeValue
Production appsRoot cause analysis during incidents
Infrastructure-as-codeConfiguration drift detection
Runbook scriptsUnderstand automation logic
Start with one

Connect your most incident-prone application first. Add more later.


What you unlocked

✅ Your agent now:

  • Analyzes source code during investigations
  • Provides file:line references for issues
  • Creates To-Do Plans showing investigation steps
  • Correlates production symptoms to code changes

Next step

Step 4: Set Up Incident Response


Learn more

Was this page helpful?