Skip to content

Resources

To deploy self-hosted GitHub Actions runners in Azure, follow these preliminary steps. These steps prepare the necessary Azure resources, including a resource group, virtual network, and service principal (SP). Each step is critical for the seamless operation of your GitHub Actions runners.

Step 1: Create a Resource Group

A resource group in Azure is a container that holds related resources for an Azure solution. Begin by creating a resource group named rg-rannable in the westeurope region. This group will organize all resources related to your self-hosted GitHub Actions runners.

Execute the following command in your terminal:

Terminal window
az group create --location westeurope --name rg-rannable

Step 2: Create a Virtual Network

Next, establish a virtual network (VNet) to securely connect Azure resources to each other. The VNet vnet-rannable will include a subnet named servers configured for the address space 10.255.0.0/24. This setup provides a private network for your runners and related services.

Run this command to create the virtual network and subnet:

Terminal window
az network vnet create --resource-group rg-rannable --name vnet-rannable --address-prefix 10.255.0.0/24 --subnet-name servers --subnet-prefixes 10.255.0.0/24

Step 3: Create a Service Principal

A service principal (SP) allows your GitHub Actions runners to interact with Azure resources under specified permissions. Here, you’ll create an SP named Rannable with the role of “Virtual Machine Contributor,” enabling it to manage virtual machines within the rg-rannable resource group.

To create the service principal, use the following command:

Terminal window
az ad sp create-for-rbac --name Rannable --role "Virtual Machine Contributor" --scopes /subscriptions/your-subscription-id/resourceGroups/rg-rannable

Note: Replace your-subscription-id with your actual Azure subscription ID.

Step 4: Obtain the Subnet ID

For network configuration and security purposes, you’ll need the subnet ID of the servers subnet within your VNet. This ID is used to associate your GitHub Actions runners with the subnet directly.

Retrieve the subnet ID by executing:

Terminal window
az network vnet subnet show --resource-group rg-rannable --vnet-name vnet-rannable --name servers --query id

Copy the output of this command, as it will be required for configuring your GitHub Actions runners’ network settings.