Azure Private Networking
Earn 25 points (50 with Pro) in two steps
- ① Read through the lesson — each section gets a ✓ as you scroll through it.
- ② When every section has a ✓, tap Complete lesson.
0 of 9 read · keep scrolling
✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro
Managing GitHub Actions Runners with Azure Private Networking
Introduction: The Security Perimeter Challenge
In the modern software development lifecycle, automation is the backbone of delivery. GitHub Actions provides a powerful way to automate workflows, but when organizations move sensitive applications into cloud environments like Azure, the default "GitHub-hosted" runners often present a security hurdle. These runners operate on the public internet, which means they do not have direct access to internal resources—such as private databases, internal APIs, or restricted container registries—without punching holes in your firewall or exposing services to the public web.
This is where the concept of Azure Private Networking for GitHub Actions runners becomes critical. By deploying "Self-Hosted Runners" directly into an Azure Virtual Network (VNet), you can ensure that your CI/CD pipelines operate entirely within your private infrastructure. This approach eliminates the need for public endpoints, reduces the attack surface of your internal services, and keeps traffic contained within the Azure backbone. Understanding how to architect, deploy, and manage these runners is a fundamental skill for any DevOps engineer tasked with maintaining a secure, compliant, and high-performance development environment.
Not read yet
Understanding the Architecture of Self-Hosted Runners in Azure
To manage runners effectively, you must first understand the fundamental shift from GitHub-hosted to self-hosted infrastructure. GitHub-hosted runners are ephemeral, managed by GitHub, and exist outside your network perimeter. Self-hosted runners, however, are virtual machines or containers that you provision, patch, and maintain. When you place these within an Azure VNet, the runner behaves as a member of your internal network.
The Role of the VNet
A Virtual Network (VNet) is the fundamental building block for your private network in Azure. When you place a runner inside a VNet, it receives a private IP address from your address space. This allows the runner to communicate with other resources in the same VNet—or peered VNets—without ever traversing the public internet. This is particularly useful for tasks like running database migrations against a private SQL instance or deploying artifacts to a private Kubernetes cluster.
Communication Flow
A common misconception is that the runner must be "reachable" from GitHub. In reality, the GitHub Actions runner agent uses an outbound-only communication model. It polls the GitHub API over HTTPS (port 443) to check for new jobs. Because the traffic is outbound, you do not need to open inbound ports on your Azure Network Security Groups (NSGs). This is a massive security benefit, as it minimizes the risk of unauthorized external access to your runner machines.
Callout: The "Pull" Model vs. "Push" Model GitHub Actions runners use a "pull" model. The runner initiates a connection to GitHub to ask if there is work to be done. This is significantly more secure than a "push" model, where a central server might try to connect to your machines. By using the pull model, your infrastructure remains hidden behind your firewall, with no need for open inbound ports, effectively neutralizing many common network-based attack vectors.
Not read yet
Preparing the Azure Environment for Private Runners
Before you deploy a single runner, you must ensure your Azure environment is correctly configured to support them. This involves setting up the VNet, configuring subnets, and ensuring that your identity management is in place.
VNet and Subnet Design
You should dedicate specific subnets to your CI/CD infrastructure. Do not mix your production application servers with your build servers. A dedicated subnet allows you to apply granular Network Security Group (NSG) rules that are specific to the needs of the runner. For instance, your build runners might need access to an Azure Container Registry (ACR) and a Key Vault, but they should not have access to your production customer database.
Network Security Group (NSG) Best Practices
When configuring NSGs for your runner subnet, follow the principle of least privilege. Your outbound rules should allow:
- Traffic to GitHub’s IP ranges (or use a Service Tag if supported) over port 443.
- Traffic to your internal resources (e.g., private endpoints for SQL, Key Vault, or storage).
- Traffic to public DNS services if you are not using a private DNS resolver.
Warning: Avoid "Any/Any" Rules A common mistake is to create an outbound rule that allows all traffic to "Any" destination. While this makes testing easier, it is a significant security risk. If a build script is compromised, the attacker could use the runner to exfiltrate data to an external server. Always restrict outbound traffic to only the specific endpoints and services your runners require.
Not read yet
Deploying Self-Hosted Runners: Step-by-Step
There are several ways to host runners in Azure: Virtual Machine Scale Sets (VMSS) or standalone Virtual Machines. For production environments, VMSS is the standard recommendation because it provides auto-scaling and ephemeral capabilities, which ensure that every job runs on a clean environment.
Step 1: Create the Runner Image
You can use an Azure Compute Gallery to store a custom image for your runners. This image should include the necessary build tools (like Docker, Node.js, Python, etc.). By pre-baking these tools into the image, you significantly reduce the time it takes for a runner to be ready to process a job.
Step 2: Configure the VMSS
When creating the VMSS, you will link it to your VNet and private subnet. You will also provide a startup script that registers the runner with your GitHub organization or repository.
# Example snippet for a startup script used in VMSS metadata
# This script installs the runner agent and registers it
mkdir actions-runner && cd actions-runner
curl -o actions-runner-linux-x64-2.300.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.300.0/actions-runner-linux-x64-2.300.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.300.0.tar.gz
./config.sh --url https://github.com/YOUR_ORG/YOUR_REPO --token YOUR_REGISTRATION_TOKEN
./run.sh
Step 3: Enabling Ephemeral Runners
To ensure your runners are secure, use the --ephemeral flag during configuration. This tells the runner to automatically unregister itself after a single job is completed. This is a best practice because it prevents "configuration drift" and ensures that if a build script modifies the system state (e.g., installing a package or changing a file), that change does not persist to the next job.
Not read yet
Networking Challenges and Solutions
Even with a solid plan, networking issues are common when moving runners to private subnets. Below are the most frequent challenges and how to resolve them.
DNS Resolution
When your runners are in a private VNet, they may lose the ability to resolve public DNS names if your VNet is not configured with an Azure DNS Resolver or a custom DNS server. If your runner cannot resolve github.com or api.github.com, it will fail to connect.
- Solution: Ensure your VNet is configured to use Azure-provided DNS or your own internal DNS servers that have conditional forwarding for external domains.
Accessing Private Endpoints
If your build process needs to communicate with an Azure SQL instance that uses a Private Endpoint, your runner must be able to resolve that endpoint's private IP.
- Solution: Use an Azure Private DNS Zone. Link the Private DNS Zone to your VNet so that the runner can resolve the internal FQDN of your SQL instance to its private IP address.
The Problem of "Egress Traffic"
If your build process requires downloading external dependencies (e.g., from npm or PyPI), and you have blocked all outbound traffic, your builds will fail.
- Solution: Implement an Azure Firewall or a NAT Gateway. This allows you to route outbound traffic through a single, controlled point where you can enforce traffic filtering (FQDN filtering) to ensure runners can only connect to authorized package repositories.
Tip: Use Service Tags Azure provides "Service Tags" that represent groups of IP addresses for Azure services. In your NSG rules, you can use tags like
AzureKeyVaultorStorageinstead of hardcoding IP addresses. This makes your network configuration much easier to maintain as Azure's internal IP ranges change.
Not read yet
Comparing Runner Deployment Options
Choosing the right deployment model is crucial for performance and cost management.
| Feature | Standalone VM | Virtual Machine Scale Set (VMSS) |
|---|---|---|
| Scaling | Manual | Automatic |
| Management | Individual | Centralized |
| Ephemerality | Difficult to enforce | Native |
| Cost | Fixed (on/off) | Variable (per job) |
| Configuration | Static | Dynamic/Image-based |
Best Practices for Managing Runners at Scale
Once you have your runners deployed, the focus shifts to maintenance and optimization. Managing a fleet of runners requires a "cattle, not pets" mentality.
1. Automated Patching
Since your runners are inside your network, they are subject to your internal security policies. Use Azure Update Manager to automate the patching of your runner OS. If you are using VMSS, you can simply update the base image in your Compute Gallery and perform a rolling upgrade of the VMSS instances to ensure all runners are running the latest, most secure version of the OS.
2. Monitoring and Logging
You should never have to log into a runner to see why a job failed. Integrate your runners with Azure Monitor and Log Analytics. By installing the Azure Monitor Agent (AMA) on your runner images, you can stream system logs, performance metrics, and even the runner agent logs directly to a workspace. This allows you to set up alerts for high CPU usage, out-of-memory errors, or runner registration failures.
3. Resource Governance
Runners can be resource-intensive. If a developer accidentally triggers a massive build that consumes all CPU, it could impact other services if they share the same underlying host (though unlikely in modern Azure). Use Azure Policy to enforce SKU limitations on your VMSS so that runners cannot be deployed with excessively large instance sizes that lead to unnecessary costs.
4. Handling "Runner Idle" Costs
One of the most common mistakes is leaving runners running 24/7. Even if they are not processing jobs, you are paying for the compute resources.
- Strategy: Configure your VMSS to scale down to zero when no jobs are pending. GitHub Actions provides specific webhooks and scaling tools (like the Actions Runner Controller for Kubernetes) that can dynamically create and destroy runners based on the queue depth.
Not read yet
Common Pitfalls to Avoid
Pitfall: Hardcoding Secrets
It is tempting to put credentials for your internal databases into the startup script of the runner. Never do this.
- Correction: Use Managed Identities. Assign a User-Assigned Managed Identity to your VMSS. Your code running on the runner can then authenticate to Azure resources (like Key Vault or SQL) using the identity of the VM, without needing to handle passwords or API keys.
Pitfall: Ignoring Network Latency
If your runner is in the East US region but your database is in West Europe, you will experience significant latency during build and deployment phases.
- Correction: Always deploy your runners in the same Azure region as the resources they interact with most frequently.
Pitfall: Over-privileged Service Accounts
If you give your runner's Managed Identity "Contributor" access to your entire subscription, a compromised build script could delete your entire production environment.
- Correction: Use the principle of least privilege. Give the identity only the specific roles (e.g., "Storage Blob Data Contributor") on the specific resources it needs to access.
Callout: The Power of Managed Identities Managed Identities are the gold standard for Azure authentication. By using them, you move away from the "secret-management nightmare" of rotating passwords and storing keys in GitHub Secrets. The runner "is" the identity, meaning it can request a token from the Azure metadata service automatically. This creates a highly secure, zero-touch authentication flow that is perfectly suited for private network environments.
Not read yet
Advanced Scenario: Actions Runner Controller (ARC)
If your organization is already using Azure Kubernetes Service (AKS), you should look into the Actions Runner Controller (ARC). ARC is a Kubernetes operator that allows you to manage runners as Kubernetes pods.
This approach offers several advantages:
- Density: You can pack multiple runners onto a single node, saving costs compared to dedicated VMs.
- Speed: Starting a pod is significantly faster than booting a VM.
- Consistency: Your runners share the same infrastructure as your applications, making it easier to manage network policies and security configurations.
When running ARC in a private VNet, you simply ensure your AKS cluster is a "Private Cluster." The runners will then be able to access internal services via the internal Kubernetes network, keeping everything contained within your private network boundaries.
Troubleshooting Connectivity
When things go wrong, the first step is always to isolate the network layer from the application layer.
- Check the Runner Logs: The runner agent logs are typically located in the
_diagfolder within the runner installation directory. Look for "connectivity" or "socket" errors. - Test Connectivity from the VM: Log into the VM (if possible) and use tools like
curlortelnetto check if you can reach your internal resources.curl -v https://your-internal-api.internalnc -zv <private-ip> <port>
- Inspect NSG Flow Logs: Enable NSG Flow Logs in Azure to see exactly which packets are being dropped by your network security rules. This is the definitive way to see if a firewall rule is blocking your traffic.
- Verify DNS: Ensure the runner is using the correct DNS server. If you have a custom DNS server in your VNet, verify that the runner is configured to use it via DHCP options on the VNet.
Not read yet
Summary: Key Takeaways for Managing Azure Runners
Successfully managing GitHub Actions runners within Azure private networks requires a combination of networking knowledge, security awareness, and operational discipline. By following these principles, you ensure your CI/CD processes remain both fast and secure.
- Prioritize Outbound-Only Traffic: Always design your network such that runners poll GitHub for jobs, rather than opening inbound ports. This is the cornerstone of a secure CI/CD network architecture.
- Embrace Ephemerality: Use VMSS or Kubernetes-based runners that destroy themselves after every job. This eliminates configuration drift and ensures a clean, predictable environment for every build.
- Leverage Managed Identities: Move away from hardcoded secrets. Use Azure Managed Identities to grant your runners access to internal resources, ensuring that credentials are never stored in your code or runner configurations.
- Implement Granular Network Controls: Use NSGs and Service Tags to restrict runner access to only the specific endpoints required for their jobs. Never allow "Any/Any" outbound traffic.
- Automate Infrastructure Lifecycle: Treat your runners like any other production workload. Use Infrastructure-as-Code (Terraform, Bicep, or ARM templates) to deploy and manage your runner fleets, ensuring consistency across environments.
- Monitor and Observe: Integrate your runners with Azure Monitor. You cannot manage what you cannot measure; having visibility into runner performance and connectivity is essential for troubleshooting.
- Align Regionality: Always deploy runners in the same Azure region as your internal services to minimize latency and avoid cross-region data transfer costs.
By treating your CI/CD infrastructure with the same level of architectural rigor as your production application, you create a robust foundation that can scale to meet the needs of any engineering organization. Whether you choose standard Virtual Machine Scale Sets or advanced Kubernetes-based controllers, the principles of private networking, least privilege, and automated lifecycle management remain the keys to success.
Not read yet
Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.
- Managed Users vs Personal Accounts
- Managed Users vs Personal Accounts Quiz5q
- Configuring SAML Single Sign-On
- Configuring SAML Single Sign-On Quiz5q
- Enforcing Two-Factor Authentication
- Enforcing Two-Factor Authentication Quiz5q
- SCIM Provisioning Implementation
- SCIM Provisioning Implementation Quiz5q
- Team Synchronization with IdP
- Team Synchronization with IdP Quiz5q
- Choosing Identity Providers
- Choosing Identity Providers Quiz5q
- Authentication and Authorization Model
- Authentication and Authorization Model Quiz5q
- Organization Roles Overview
- Organization Roles Overview Quiz5q
- Repository Roles Configuration
- Repository Roles Configuration Quiz5q
- Enterprise Teams Management
- Enterprise Teams Management Quiz5q
- Auditing Access and Permissions
- Auditing Access and Permissions Quiz5q
- Managing Policies and Rulesets
- Managing Policies and Rulesets Quiz5q
- Admin vs GitHub Support Responsibilities
- Admin vs GitHub Support Responsibilities Quiz5q
- Generating Support Bundles
- Generating Support Bundles Quiz5q
- Creating Diagnostics Reports
- Creating Diagnostics Reports Quiz5q
- Developer Process Standards
- Developer Process Standards Quiz5q
- Workflow and Branching Standards
- Workflow and Branching Standards Quiz5q
- GHEC with Enterprise Managed Users
- GHEC with Enterprise Managed Users Quiz5q
- GHEC with Data Residency
- GHEC with Data Residency Quiz5q
- GHEC with Personal Accounts
- GHEC with Personal Accounts Quiz5q
- GitHub Enterprise Server Deployment
- GitHub Enterprise Server Deployment Quiz5q
- Licensing and Billing Models
- Licensing and Billing Models Quiz5q
- Monitoring License Usage
- Monitoring License Usage Quiz5q
- Organization Security Policies
- Organization Security Policies Quiz5q
- Enterprise Security Policies
- Enterprise Security Policies Quiz5q
- Enterprise Security Posture
- Enterprise Security Posture Quiz5q
- Data Protection Strategies
- Data Protection Strategies Quiz5q
- Audit Logging Implementation
- Audit Logging Implementation Quiz5q
- Security Reporting and Compliance
- Security Reporting and Compliance Quiz5q
- Vulnerability Alerts Configuration
- Vulnerability Alerts Configuration Quiz5q
- Secret Scanning Setup
- Secret Scanning Setup Quiz5q
- CodeQL Code Scanning
- CodeQL Code Scanning Quiz5q
- Dependabot Configuration
- Dependabot Configuration Quiz5q
- Security Advisories Management
- Security Advisories Management Quiz5q
- Security Response Planning
- Security Response Planning Quiz5q
- Runner Groups Configuration
- Runner Groups Configuration Quiz5q
- GitHub-Hosted vs Self-Hosted
- GitHub-Hosted vs Self-Hosted Quiz5q
- IP Allow Lists Configuration
- IP Allow Lists Configuration Quiz5q
- Azure Private Networking
- Azure Private Networking Quiz5q
- Runner Performance Monitoring
- Runner Performance Monitoring Quiz5q
- Troubleshooting Runner Issues
- Troubleshooting Runner Issues Quiz5q
- Enterprise Migration Strategies
- Enterprise Migration Strategies Quiz5q
- Backup and Disaster Recovery
- Backup and Disaster Recovery Quiz5q
- High Availability Configuration
- High Availability Configuration Quiz5q
- Upgrade Planning and Execution
- Upgrade Planning and Execution Quiz5q
- Performance Tuning
- Performance Tuning Quiz5q
- Compliance and Regulatory Requirements
- Compliance and Regulatory Requirements Quiz5q
- Common Administration Issues
- Common Administration Issues Quiz5q
- Debugging Authentication Problems
- Debugging Authentication Problems Quiz5q
- Network Connectivity Issues
- Network Connectivity Issues Quiz5q
- Working with GitHub Support
- Working with GitHub Support Quiz5q
- Log Analysis and Debugging
- Log Analysis and Debugging Quiz5q
- Enterprise Maintenance Windows
- Enterprise Maintenance Windows Quiz5q
No GH-100 practice exam yet
Your points already work on 76 Amazon, CompTIA and Microsoft exams.
See the exams