Azure AI Foundry with Anthropic Claude Part 6: Claude Code + Azure DevOps Integration – Automated Development Workflows

Azure AI Foundry with Anthropic Claude Part 6: Claude Code + Azure DevOps Integration – Automated Development Workflows

Claude Code transforms development workflows by bringing AI-powered coding assistance directly into your development environment and CI/CD pipelines. This guide demonstrates integrating Claude Code with Azure AI Foundry and Azure DevOps for automated code generation, review, testing, and deployment workflows.

Claude Code Setup with Azure Foundry

Environment Configuration

# Enable Azure Foundry integration
export CLAUDE_CODE_USE_FOUNDRY=1

# Azure resource configuration
export ANTHROPIC_FOUNDRY_RESOURCE=your-resource-name
# Or use full base URL:
# export ANTHROPIC_FOUNDRY_BASE_URL=https://your-resource-name.services.ai.azure.com

# Model deployment names
export ANTHROPIC_DEFAULT_SONNET_MODEL='claude-sonnet-4-5'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='claude-haiku-4-5'
export ANTHROPIC_DEFAULT_OPUS_MODEL='claude-opus-4-5'

Authentication

# Option 1: API Key
export ANTHROPIC_FOUNDRY_API_KEY=your-api-key

# Option 2: Azure CLI (Entra ID)
az login
# Claude Code automatically uses DefaultAzureCredential

Project Context with CLAUDE.md

Create CLAUDE.md in your project root to provide context:

# Project: Enterprise API Service

## Overview
RESTful API built with Node.js/Express, deployed to Azure App Service.
Uses Claude Sonnet 4.5 for intelligent data processing.

## Tech Stack
- Node.js 20 LTS
- Express 4.x
- TypeScript 5.x
- Azure AI Foundry (Claude integration)
- Azure App Service
- Azure Key Vault

## Architecture
- `src/api/` - API route handlers
- `src/services/` - Business logic layer
- `src/infrastructure/` - Azure integrations
- `tests/` - Jest unit and integration tests

## Commands
```bash
npm run dev      # Local development
npm run build    # TypeScript compilation
npm test         # Run test suite
npm run deploy   # Deploy to Azure
```

## Code Patterns
- Use async/await for all async operations
- Apply dependency injection for services
- Follow repository pattern for data access
- Use Azure KeyVault for secrets

## Current Sprint
- Implementing prompt caching for cost optimization
- Adding streaming response support
- Enhancing error handling with retry logic

GitHub Actions Integration

name: Claude Code Review

on:
  pull_request:
    paths:
      - 'src/**'
      - 'tests/**'

jobs:
  claude-review:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    
    steps:
      - uses: actions/checkout@v4
      
      - name: Claude Code Review
        uses: anthropic-ai/claude-code-action@v1
        with:
          prompt: |
            Review the changed files for:
            1. Code quality and best practices
            2. Potential bugs or security issues
            3. Performance optimizations
            4. Test coverage gaps
            
            Provide specific, actionable feedback.
          
          allowed_tools: "edit,write,bash"
        
        env:
          CLAUDE_CODE_USE_FOUNDRY: "1"
          ANTHROPIC_FOUNDRY_RESOURCE: ${{ secrets.AZURE_FOUNDRY_RESOURCE }}
          ANTHROPIC_FOUNDRY_API_KEY: ${{ secrets.AZURE_FOUNDRY_API_KEY }}

Automated Test Generation

name: Generate Tests

on:
  pull_request:
    paths:
      - 'src/services/**'

jobs:
  generate-tests:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v4
      
      - name: Generate Unit Tests
        uses: anthropic-ai/claude-code-action@v1
        with:
          prompt: |
            Review changed service files and generate Jest tests.
            Follow patterns in tests/services/example.test.ts.
            Ensure >80% code coverage.
          
          allowed_tools: "write,edit"
        
        env:
          CLAUDE_CODE_USE_FOUNDRY: "1"
          ANTHROPIC_FOUNDRY_RESOURCE: ${{ secrets.AZURE_FOUNDRY_RESOURCE }}
          ANTHROPIC_FOUNDRY_API_KEY: ${{ secrets.AZURE_FOUNDRY_API_KEY }}
      
      - name: Commit Generated Tests
        run: |
          git config user.name "Claude Code Bot"
          git config user.email "bot@example.com"
          git add tests/
          git commit -m "chore: add generated tests" || echo "No changes"
          git push

Azure DevOps Pipeline

trigger:
  branches:
    include:
      - main
      - develop

pool:
  vmImage: 'ubuntu-latest'

variables:
  - group: claude-foundry-secrets

stages:
  - stage: CodeReview
    jobs:
      - job: ClaudeAnalysis
        steps:
          - task: Bash@3
            displayName: 'Install Claude Code'
            inputs:
              targetType: 'inline'
              script: |
                npm install -g @anthropic-ai/claude-code
          
          - task: Bash@3
            displayName: 'Run Claude Code Analysis'
            env:
              CLAUDE_CODE_USE_FOUNDRY: '1'
              ANTHROPIC_FOUNDRY_RESOURCE: $(FOUNDRY_RESOURCE)
              ANTHROPIC_FOUNDRY_API_KEY: $(FOUNDRY_API_KEY)
            inputs:
              targetType: 'inline'
              script: |
                claude "Analyze codebase for security vulnerabilities and code quality issues"
  
  - stage: Build
    dependsOn: CodeReview
    jobs:
      - job: BuildAndTest
        steps:
          - task: NodeTool@0
            inputs:
              versionSpec: '20.x'
          
          - script: npm ci
            displayName: 'Install dependencies'
          
          - script: npm run build
            displayName: 'Build'
          
          - script: npm test
            displayName: 'Run tests'

Automated Documentation

name: Update Documentation

on:
  push:
    branches:
      - main
    paths:
      - 'src/**'

jobs:
  update-docs:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v4
      
      - name: Generate API Documentation
        uses: anthropic-ai/claude-code-action@v1
        with:
          prompt: |
            Update README.md with current API endpoints.
            Generate OpenAPI spec from route handlers.
            Update architecture diagrams if needed.
          
          allowed_tools: "write,edit,bash"
        
        env:
          CLAUDE_CODE_USE_FOUNDRY: "1"
          ANTHROPIC_FOUNDRY_RESOURCE: ${{ secrets.AZURE_FOUNDRY_RESOURCE }}
          ANTHROPIC_FOUNDRY_API_KEY: ${{ secrets.AZURE_FOUNDRY_API_KEY }}

Conclusion

Claude Code integration with Azure DevOps automates code review, test generation, and documentation while maintaining enterprise security through Azure Foundry. Part 7 will cover comprehensive production patterns including monitoring, cost optimization, and scaling strategies.

References

Written by:

555 Posts

View All Posts
Follow Me :