Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

azd app Demo Project

This demo project showcases how to use azd app with AI-powered debugging through the MCP (Model Context Protocol) integration with GitHub Copilot, and demonstrates the unified testing framework.

📚 Full Documentation: jongio.github.io/azd-app

Prerequisites

You'll need the Azure Developer CLI (azd) installed. Choose your platform:

Windows:

winget install microsoft.azd

macOS:

brew tap azure/azd && brew install azd

Linux:

curl -fsSL https://aka.ms/install-azd.sh | bash

Install azd app

Install the azd app extension:

# Add extension source
azd extension source add -n jongio -t url -l https://jongio.github.io/azd-extensions/registry.json

# Install the extension
azd extension install jongio.azd.app

Quick Start

# Install dependencies
azd app deps

# Start the API service
azd app run

# Run tests with coverage
azd app test --coverage

Testing with azd app test

This demo showcases the azd app test command for unified test execution.

Running Tests

# Run all tests for all services
azd app test

# Run only unit tests
azd app test --type unit

# Run tests with coverage collection
azd app test --coverage

# Run tests with coverage threshold enforcement
azd app test --coverage --threshold 80

# Run tests for a specific service
azd app test --service api

# Verbose output showing test details
azd app test --verbose

# Dry run to see what would be tested
azd app test --dry-run

Test Configuration

The azure.yaml file contains test configuration:

# Global test configuration
test:
  parallel: true
  outputDir: ./test-results
  coverage:
    enabled: true
    threshold: 70

services:
  api:
    test:
      unit:
        command: npm test
      integration:
        command: npm run test:integration
      coverage:
        threshold: 80

Test Files

The demo includes a test file (api/server.test.js) that:

  • Tests all CRUD operations (GET, POST, DELETE)
  • Validates input handling
  • Tests error cases (404, 400 responses)
  • Includes proper validation (demonstrating what the "bug" should have)

Coverage Reports

When running with --coverage, reports are generated in:

  • ./test-results/ - Aggregated coverage reports
  • ./api/coverage/ - Service-specific coverage

Demonstrating AI Debugging

This project includes an intentional bug for demonstrating AI debugging capabilities.

The Bug

The API's /items endpoint doesn't validate the price field. When you POST an item without a price, the tax calculation fails:

# This works correctly
curl -X POST http://localhost:3000/items -H "Content-Type: application/json" -d '{"name": "Widget", "price": 10}'

# This triggers the bug (missing price)
curl -X POST http://localhost:3000/items -H "Content-Type: application/json" -d '{"name": "Broken Widget"}'

Using Copilot to Debug

  1. Run the service with azd app run

  2. Trigger the bug with the curl command above

  3. Open GitHub Copilot Chat (Ctrl+Shift+I on Windows/Linux or Cmd+Shift+I on macOS) and ask:

    "Check the API logs for errors"

    Copilot uses the MCP tools to call get_service_logs and shows you the error.

  4. Ask Copilot:

    "Why is the total calculation failing?"

    Copilot analyzes the logs and code to identify the missing validation.

  5. Ask Copilot:

    "Fix the price validation bug"

    Copilot suggests adding input validation for the price field.

MCP Configuration

The .vscode/mcp.json file configures the azd app MCP server for Copilot:

{
  "servers": {
    "Azure Developer CLI - App Extension": {
      "command": "azd",
      "args": ["app", "mcp", "serve"]
    }
  }
}

Available MCP Tools

When debugging with Copilot, 10 tools are available across three categories:

Observe

Tool Description
get_services List all services with status, ports, and health
get_service_logs Fetch logs with optional filtering by level and time
get_project_info Get azure.yaml configuration

Operate

Tool Description
run_services Start all or specific services
stop_services Stop all or specific services
restart_service Restart a specific service
install_dependencies Install dependencies for services

Configure

Tool Description
check_requirements Verify prerequisites (Node.js, Python, etc.)
get_environment_variables Get environment variables (sensitive values redacted)
set_environment_variable Set an environment variable for a service

See the full MCP Tools Reference for detailed documentation.

Project Structure

demo/
├── azure.yaml          # Service and test configuration
├── test-results/       # Aggregated test/coverage reports (generated)
├── .vscode/
│   └── mcp.json        # MCP server configuration
├── api/
│   ├── package.json    # Node.js dependencies and test scripts
│   ├── server.js       # API with intentional bug
│   ├── server.test.js  # Unit tests for the API
│   └── coverage/       # Service coverage reports (generated)
└── README.md           # This file

Endpoints

Method Path Description
GET /items List all items
POST /items Create item (bug: no price validation)
GET /items/:id Get item by ID
DELETE /items/:id Delete item

CLI Commands Reference

Command Description
azd app deps Install dependencies for all services
azd app run Start all services
azd app stop Stop all services
azd app test Run tests for all services
azd app test --coverage Run tests with coverage collection
azd app test --type unit Run only unit tests
azd app logs View service logs

Learn More

About

Demo app for azd app extension

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages