L10. Runner and Agent Infrastructure: GitHub-Hosted vs Self-Hosted
Course outlineLesson 10 of 18
Choose pipeline execution infrastructure by connectivity, tooling, isolation, limits, and ownership. GitHub-hosted private networking and Azure scale set pools expand the choices beyond a single self-hosted machine.
Hosted and self-hosted execution
Azure Pipelines runs jobs on agents; GitHub Actions runs them on runners. Standard Microsoft-hosted agents and most GitHub-hosted runners provide a fresh VM for each job. The provider maintains the host image, while your team still secures workflow code, permissions, dependencies, and secrets. GitHub's single-CPU hosted runners use containers rather than a dedicated VM.
Self-hosted agents and runners let you control the machine, installed software, network routes, and update schedule. Your team owns patching, hardening, capacity, cleanup, and isolation. Neither model makes untrusted pipeline code safe by itself.
Compare connectivity, tooling, and limits
| Decision | Microsoft-hosted Azure agent | GitHub-hosted runner | Self-hosted machine |
|---|---|---|---|
| Private connectivity | No direct VPN or ExpressRoute connection to your corporate network | Private networking options include WireGuard overlays and Azure VNet integration | Possible when you configure routes, DNS, and firewalls |
| Tools | Preinstalled image plus tools installed during the job | Preinstalled image plus job-time installation | Custom image and persistent tool installation |
| Job limits | Hosted job time and parallel-job entitlements apply | VM-based hosted jobs allow up to 6 hours; single-CPU containers allow 15 minutes; concurrency depends on account and runner type | Service and configured timeout limits still apply; GitHub self-hosted job execution is capped at 5 days |
| Ownership | Provider manages the host; you secure the pipeline | Provider manages the host; you secure the workflow | You secure both the host and pipeline |
Agent pools, capabilities, and authorization
In Azure DevOps Services, agent pools are organization-scoped and can be shared through project pools. A job uses one agent. For self-hosted agents, capabilities describe the machine and its software, and job demands select an eligible agent. Matching a demand does not authorize a pipeline: restrict pool permissions and pipeline access separately. Pipeline permissions restrict YAML pipelines; Classic pipeline access depends on pool security roles.
Elastic scale set agents
Azure Pipelines can manage a self-hosted pool backed by an Azure Virtual Machine Scale Set. Configure the VM image, network, capacity limits, and standby capacity. Disable Azure VM Scale Set autoscaling so Azure Pipelines controls scaling from queued jobs. Your team still owns the image and its security. Configure reimaging after each job where clean isolation is required.
Ephemeral and persistent isolation
Persistent self-hosted machines can retain workspaces, credentials, caches, and malicious changes. Ephemeral runners reduce cross-job persistence when their environment is destroyed and rebuilt; shared caches and external services still need controls. Merely unregistering a runner does not wipe its machine.
Public fork pull requests can execute attacker-controlled code on a self-hosted machine. Private repositories also require trust boundaries between contributors, workflows, and deployment credentials. Restrict repository and runner-group access, review workflow changes, isolate untrusted builds from privileged deployment pools, and scope tokens narrowly. Approval is one layer, not a substitute for isolation. Exam decision: Use a network-connected self-hosted agent for an on-premises deployment when Microsoft-hosted Azure agents cannot reach the target. For GitHub Actions, also evaluate supported hosted private-networking options before deciding who must operate the runner.
References
- AZ-400 skills outline
- Microsoft-hosted Azure Pipelines agents
- Azure Pipelines Agents - Azure Pipelines
- Create and Manage Agent Pools - Azure Pipelines
- Azure Virtual Machine Scale Set agents - Azure Pipelines
- Private networking with GitHub-hosted runners
- Actions limits - GitHub Docs
- Secure use reference - GitHub Docs
- GitHub-hosted runner reference
Continue Learning
- ✓Microsoft-hosted Azure agents lack direct corporate VPN or ExpressRoute connectivity; GitHub-hosted runners support configured private networking, and both services enforce job and concurrency limits
- ✓Self-hosted agents/runners can reach private/on-premises resources and pre-install specific licensed tooling, at the cost of the team owning patching, security hardening, and lifecycle management
- ✓Key decision factors between hosted and self-hosted are cost at scale, whether specific licensed tools must persist on the machine, network connectivity requirements, and who is responsible for ongoing maintenance
- ✓Azure DevOps scale set agents back a self-hosted-style agent pool with a VM scale set, combining private network reach with hosted-like elastic auto-scaling
- ✓Using self-hosted runners with public repositories is a significant security risk, since a malicious pull request from an outside contributor could execute arbitrary code on that self-hosted infrastructure; restricting self-hosted runners to private repos or requiring workflow approval mitigates this
1. A pipeline needs to deploy to an on-premises SQL Server that is only reachable from inside the corporate network, which Microsoft-hosted agents cannot reach. What is the appropriate solution?
2. What is a well-documented security risk of enabling self-hosted runners for a public GitHub repository without additional restrictions?
3. What benefit does an Azure DevOps scale set agent pool provide compared to a single, manually managed self-hosted agent VM?