GitLab Runner Azure

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up a gitlab runner azure workflow, deploy the runner software on an Azure virtual machine or container cluster. Then register that host with your GitLab project using a runner token. Many engineering teams start by giving the runner host a broad cloud role. That setup lets every pipeline job read and write across the whole cloud account. If one build script has a flaw, it can change or delete critical cloud resources. How a gitlab runner azure architecture works A GitLab runner is a sm

Azure RBAC + GitLab CI Security: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

To set up a gitlab runner azure workflow, deploy the runner software on an Azure virtual machine or container cluster. Then register that host with your GitLab project using a runner token. Many engineering teams start by giving the runner host a broad cloud role. That setup lets every pipeline job read and write across the whole cloud account. If one build script has a flaw, it can change or delete critical cloud resources.

How a gitlab runner azure architecture works

A GitLab runner is a small background agent that runs your build and deploy jobs. When you host it on Azure, the agent polls your GitLab server for new work. Once a developer pushes code, GitLab sends the job steps to your Azure host. The runner pulls your source code and runs the build commands inside a fresh executor.

Teams choose between two main ways to host this agent on Azure. Some teams install the agent on a single Linux or Windows virtual machine. This simple setup works well for small teams with steady build loads. Other teams run the agent inside an Azure Kubernetes Service cluster. The cluster starts a new pod for each job and deletes it when the work ends. Both options can store build cache files in Azure Blob Storage to speed up future runs.

To deploy apps or change cloud resources, the runner must log in to Azure. Teams used to store static client secrets in GitLab project variables. Now, most teams use either an Azure managed identity or OpenID Connect tokens. With a managed identity, the Azure host logs in without any saved password. With OpenID Connect, GitLab sends a short token to Azure for each job. Azure checks the token and grants the job a cloud role for that single run.

What native cloud roles solve and what they miss

Native cloud roles and OpenID Connect tokens solve a major problem for build pipelines. You no longer need to paste long-lived cloud keys into your GitLab settings. You also do not have to rotate static passwords by hand every few months. Cloud logs will show which runner identity logged in and started a session.

Still, cloud roles only check who logs in at the start of a job. Once the runner has a valid session, Azure trusts every command inside that role. A runner that needs to run one database update often gets full database write permissions. A runner that checks a Kubernetes cluster often gets broad cluster admin rights.

Azure RBAC + GitLab CI Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

This creates a blind spot during the actual job run. Cloud role logs show that a runner accessed a database or server. They do not show the exact SQL statements or shell commands the job ran. Also, build logs can print sensitive data like emails, phone numbers, or card numbers. Native cloud roles cannot rewrite those matched fields in query results before they hit the job log. If a bad script runs inside your pipeline, broad roles cannot stop a bad command in flight.

Ways to tighten runner permissions in Azure

Start by splitting your runners by job type and risk level. Do not use one big runner pool for both code tests and production deploys. Create separate runners for testing, staging, and production work. Give the test runners zero cloud roles so they can only compile code and run unit tests.

For deploy runners, scope each Azure role down to a single resource group. Use branch rules in GitLab so only protected branches can trigger those deploy runners. This stops a random feature branch from using your production cloud role. Even with tight roles, teams still need visibility into the exact commands and queries their runners execute.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Should I use a virtual machine or Kubernetes for my runner on Azure?

Use a single virtual machine if your team has a small, predictable number of daily builds. Choose Azure Kubernetes Service if you need to scale from zero to many parallel jobs on demand.

Is a managed identity better than OpenID Connect for GitLab jobs?

OpenID Connect is safer when many projects share the same runner host. It assigns a cloud role to each specific job instead of giving one role to the whole machine.

How do I stop build logs from leaking sensitive data?

Keep production data out of test runs whenever possible. For jobs that touch real systems, use data masking to rewrite emails, phone numbers, and card numbers in results.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.