Contents

Azure Pipelines Container Agents for Azure Devops

Create self-hosted Azure Pipelines Container Agents for Azure Devops.

PipelineBuild Status
PipelineAgentshttps://dev.azure.com/GeekClub/Azure%20(Public)/_apis/build/status/PipelineAgents?branchName=master

Overview

The following explains how to easily build, setup and run self-hosted docker container agents using Azure Pipelines in Azure DevOps (ADO). The pipeline does the following for you:

  1. Creates an Azure Container Registry (ACR).
  2. Builds Docker Container Image for self-hosted Azure Pipelines Agent within that ACR.
  3. Starts Docker Container as Azure Container Instances (ACI).
  4. Connects ACIs to your Azure DevOps Agent Pool (Self-Hosted).

Repository

github.com/segraef/apa

Requirements

Setup

  1. Create an Azure DevOps Agent pool within your Azure DevOps organization.

  2. Generate a Personal Access Token (PAT) for your Azure DevOps Organization. When generating the (PAT), assign the following scopes:

    • Agent Pools - Read & Manage
    • Deployment Groups - Read & Manage
  3. Create a new repository and clone/fork this repo into it.

  4. In Pipelines/Library add a variable group named vg.PipelineAgents, with the following variable to avoid exposing keys & secrets in code

    1
    
    agentPoolToken      = <agentPoolToken>      # personal acces token for agent pool
    
  5. In parameters.yml adjust following variables

    1
    2
    3
    4
    5
    6
    
    acrName             = <acrName>                             # Azure Container Registry Name (needs to be unique)
    adoUrl              = https://dev.azure.com/<organization>  # Azure DevOps Organization URL
    agentPool           = <agentPool>                           # agent-pool name
    location            = <location>                            # where your resources will be created
    resourceGroupName   = <resourceGroupName>                   # where your agents will be placed
    serviceConnection   = <serviceConnection>                   # arm service connection name
    
  6. Create a new pipeline using the pipeline.yaml and run it.

Helper Scripts

Instead using an Azure Pipeline you can also run also these tasks locally using your local machine as agent. For that you can find a Helper file here.

If you’re not familiar with Docker at all I recommend the Docker Quickstart.

Docker Container image contents

The docker container images are based on the official Azure Pipelines VM images for Microsoft-hosted CI/CD.

Ubuntu / Debian

  • Azure CLI (latest)
  • Git (latest)
  • PowerShell Core (latest)
  • .NET SDK (2.1)
  • Docker (18.06).3-ce
  • Kubectl (1.14.4)
  • Terraform (0.12.6)

Windows Server Core (ltsc2019)

  • Chocolatey (latest)
  • Azure CLI (latest)
  • Git (latest)
  • PowerShell Core (latest)
  • Docker (in porgress)
  • Kubectl (in porgress)
  • Terraform (in porgress)