Self-Hosted Azure DevOps Agents on Hetzner Cloud - Overview¶
Introduction¶
This guide provides a comprehensive overview of setting up and managing self-hosted Azure DevOps agents on Hetzner Cloud. Self-hosted agents solve common issues with Microsoft-hosted agents, including:
- Disk space limitations: Full control over storage allocation
- Cost optimization: Significant savings for multiple parallel jobs
- Build performance: Persistent caches and pre-installed dependencies
- Unlimited job duration: No 60-minute timeout restrictions
- Custom toolchains: Install exactly what your pipelines need
Architecture¶
graph TB
subgraph AzureDevOps["Azure DevOps Organization"]
Pool1["Hetzner-Linux Pool"]
Pool2["Hetzner-Windows Pool"]
end
subgraph HetznerCloud["Hetzner Cloud"]
LinuxVM1["Linux Agent 1<br/>Ubuntu 22.04"]
LinuxVM2["Linux Agent 2<br/>Ubuntu 22.04"]
WindowsVM1["Windows Agent 1<br/>Windows Server 2022"]
WindowsVM2["Windows Agent 2<br/>Windows Server 2022"]
end
subgraph Pipelines["Azure Pipelines"]
LinuxPipeline["Linux Pipeline<br/>ubuntu-latest"]
WindowsPipeline["Windows Pipeline<br/>windows-latest"]
end
Pool1 --> LinuxVM1
Pool1 --> LinuxVM2
Pool2 --> WindowsVM1
Pool2 --> WindowsVM2
LinuxPipeline --> Pool1
WindowsPipeline --> Pool2
Cost Analysis¶
Infrastructure Costs (Hetzner Cloud)¶
Monthly Server Costs:
- Linux Agent (CPX32): ~€12-15/month × 2 = ~€24-30
- Windows Agent (CCX23): €25.90/month × 2 = €51.80
- Total Infrastructure: ~€75.80-81.80/month
Additional Costs: - Network traffic: Included (generous limits) - Backups: Optional, ~€2-5/month per server - Monitoring: Optional third-party services - Ollama (Optional): Free - Local AI inference, no API costs. See Ollama Installation Guide
Azure DevOps Costs with Self-Hosted Agents¶
Self-Hosted Agent Pricing:
- Free Tier: Unlimited parallel jobs with self-hosted agents
- No per-job charges: Self-hosted agents do not consume Microsoft-hosted agent minutes
- Organization costs: Standard Azure DevOps organization fees apply (if applicable)
Microsoft-Hosted Agent Pricing (for comparison):
- Free Tier: 1,800 minutes/month (shared across all pipelines)
- Paid Parallel Jobs:
- 1 parallel job: Free (included with Basic plan)
- Additional parallel jobs: $40/month per parallel job
- Example: 4 parallel jobs = $120/month (3 additional × $40)
Cost Comparison Example:
| Scenario | Microsoft-Hosted | Self-Hosted (Hetzner) | Savings |
|---|---|---|---|
| 1 parallel job | $0/month | €75.80-81.80/month | -€75.80-81.80 |
| 2 parallel jobs | $40/month | €75.80-81.80/month | ~€5-10/month |
| 4 parallel jobs | $120/month | €75.80-81.80/month | ~€44-50/month |
| 8 parallel jobs | $280/month | €151.60-163.60/month (2× servers) | ~€128-140/month |
Break-even Analysis:
- Break-even point: ~2 parallel jobs
- Cost savings: Significant at 4+ parallel jobs
- Additional benefits:
- No job duration limits (Microsoft-hosted: 60 minutes on free tier)
- Full control over disk space and storage
- Persistent build caches (faster builds)
- Pre-installed tools and dependencies
- Local AI inference with Ollama (optional, free, no API costs)
Total Cost of Ownership (TCO)¶
First Year: - Infrastructure: €75.80-81.80/month × 12 = €909.60-981.60/year - Setup time: ~8-16 hours (one-time) - Maintenance: ~2-4 hours/month
Ongoing: - Infrastructure: €75.80-81.80/month - Maintenance: ~2-4 hours/month - Updates: Included in maintenance time
ROI Calculation: - If using 4+ parallel jobs: Saves ~\(50/month vs Microsoft-hosted - Annual savings: ~\)600/year (€550/year) - Payback period: ~1.5 years (including setup time) - After payback: ~€550/year savings + improved build performance
Implementation Approaches¶
Option A: Manual Setup¶
Recommended for: Initial implementation, learning, small teams
Advantages: - Faster initial setup - Better for learning and understanding the system - Easier troubleshooting for first-time setup - No additional tooling required
See: Linux Setup Guide and Windows Setup Guide
Option B: Terraform Setup¶
Recommended for: Production environments, scaling, infrastructure as code
Advantages: - Infrastructure as Code (version controlled) - Reproducible deployments - Automated scaling and management - Integration with CI/CD pipelines
Quick Start¶
- Choose implementation approach (Manual or Terraform)
- Set up authentication - See Connection and Authentication Guide
- Generate SSH keys for Linux servers (recommended)
- Get RDP credentials for Windows servers
- Purchase Hetzner Cloud servers (Linux and Windows) or set up Terraform configuration
- Set up first Linux agent - See Linux Setup Guide
- Set up first Windows agent - See Windows Setup Guide
- Install Ollama (Optional) - See Ollama Installation Guide if you need AI functionality
- Configure Azure DevOps agent pools - See Agent Pools Configuration
- Update pipelines to use self-hosted agent pools
- Establish monitoring - See Maintenance Guide
Documentation Structure¶
- Overview - This document (architecture, costs, overview)
- Connection and Authentication - SSH keys, RDP access, authentication methods
- Linux Setup - Manual Linux agent setup guide
- Windows Setup - Manual Windows agent setup guide
- Ollama Installation - Install and configure Ollama for AI functionality (optional)
- Terraform Setup - Infrastructure as Code approach
- Agent Pools Configuration - Azure DevOps pool setup
- Maintenance - Monitoring and maintenance procedures
- Troubleshooting - Common issues and solutions
Server Recommendations¶
Linux Agents (Ubuntu 22.04 LTS)¶
- Recommended: CPX32
- CPX32: 6 vCPU, 12 GB RAM, 200 GB SSD (~€12-15/month) - Recommended for production
- Alternative options:
- CPX31: 4 vCPU, 8 GB RAM, 160 GB SSD (~€8.90/month) - For light builds
- CPX41: 8 vCPU, 16 GB RAM, 240 GB SSD (~€17.90/month) - For heavy builds
- For heavy builds: CCX23 (Dedicated CPU, 4 vCPU, 8 GB RAM, 160 GB SSD, ~€25.90/month)
Windows Agents (Windows Server 2022)¶
- Minimum: CCX23 (Dedicated CPU required for Windows)
- 4 vCPU, 8 GB RAM, 160 GB SSD (~€25.90/month)
- Recommended: CCX33
- 8 vCPU, 16 GB RAM, 240 GB SSD (~€49.90/month)
Key Benefits¶
- Cost Savings: Break-even at 2 parallel jobs, significant savings at 4+
- Performance: Persistent build caches and pre-installed tools
- Control: Full control over disk space, storage, and tooling
- Flexibility: No job duration limits, custom configurations
- Scalability: Easy to add/remove agents as needed
Next Steps¶
- Review the Linux Setup Guide for Linux agent installation
- Review the Windows Setup Guide for Windows agent installation
- Consider Terraform Setup for automated infrastructure management
- Configure Agent Pools in Azure DevOps
- Set up Monitoring and Maintenance procedures