ADO Pipelines Operations & Infrastructure
When to Use
- Setting up self-hosted agent pools and registering agents
- Creating and managing service connections (Azure, GitHub, Docker, etc.)
- Managing variable groups and secure files (Library)
- Configuring deployment environments with approvals and checks
- Auditing and governing pipeline resource access
Core Jobs
1. Agent Pool Management
# List agent pools
az pipelines agent pool list --org https://dev.azure.com/MyOrg --output table
# List agents in pool
az pipelines agent list \
--pool-id 5 \
--org https://dev.azure.com/MyOrg \
--output table
Self-hosted agent registration:
# Download agent, then configure
./config.sh \
--url https://dev.azure.com/MyOrg \
--auth pat \
--token $PAT \
--pool "SelfHosted-Linux" \
--agent "agent-01" \
--unattended
# Install as service
sudo ./svc.sh install
sudo ./svc.sh start
Agent pool types:
- Microsoft-hosted — managed, fresh VM per job, no maintenance, costs per parallel job
- Self-hosted — your VMs, full control, pre-installed tools, behind firewall access, no per-minute cost
- Scale set agents — Azure VMSS auto-scales based on demand (best of both)
2. Service Connections
# Create Azure Resource Manager service connection
az devops service-endpoint azurerm create \
--azure-rm-service-principal-id $SP_ID \
--azure-rm-subscription-id $SUB_ID \
--azure-rm-subscription-name "Production" \
--azure-rm-tenant-id $TENANT_ID \
--name "Azure-Production" \
--project MyProject
# List service connections
az devops service-endpoint list --project MyProject --output table
Service connection types and use cases:
| Type |
Use case |
| Azure Resource Manager |
Deploy to Azure (App Service, AKS, etc.) |
| Docker Registry |
Push/pull container images |
| GitHub |
Checkout private repos, trigger from GitHub |
| Kubernetes |
Deploy to AKS/any cluster |
| Generic |
Custom REST APIs, webhooks |
Security: Grant "Project Collection Build Service" only — not broad contributor access.
3. Library — Variable Groups & Secure Files
# Create variable group
az pipelines variable-group create \
--name "Production-Config" \
--variables ENV=prod DB_HOST=prod.db.company.com \
--project MyProject
# Add secret variable
az pipelines variable-group variable create \
--group-id 5 \
--name "DB_PASSWORD" \
--value "secret123" \
--secret true \
--project MyProject
Link to Azure Key Vault:
- Variable group → Link secrets from Azure Key Vault → select secrets
- Requires service connection with Key Vault access
- Secrets auto-refresh on pipeline run
4. Environments & Approvals
# Create environment
az pipelines environment create \
--name "production" \
--project MyProject
Add approval check via UI: Environment → Approvals and checks → Add → Approvals
- Set approvers, timeout (default 30 days), instructions
- Allow pipeline to self-approve: disable for prod
Environment resources: VMs and Kubernetes clusters can be registered as resources for deployment target tracking.
Key Concepts
- Agent pool — collection of agents that can run pipeline jobs
- Service connection — authenticated connection to external service (Azure, Docker, GitHub)
- Variable group — shared variables across multiple pipelines (vs pipeline-specific variables)
- Secure file — binary files (certificates, provisioning profiles) stored encrypted
- Environment — logical target (dev/staging/prod) with history, approvals, and resource tracking
- Scale set agents — auto-scaling agent pool backed by Azure VMSS
Checklist
Key Outputs
- Agent pools registered and agents online
- Service connections created with least-privilege service principals
- Variable groups with Key Vault linking for secrets
- Environments with approvals for production
Output Format
- 🔴 Critical — service connection using personal PAT (breaks on offboarding), no approval on production environment, secrets hardcoded in pipeline YAML
- 🟡 Warning — all pipelines using single service connection (no isolation), no environment resource tracking, variable groups without Key Vault
- 🟢 Suggestion — use scale set agents for variable workloads, link variable groups to Key Vault, add Exclusive Lock check for sequential deployments
Anti-Patterns
- Service connections using personal user credentials (offboarding breaks pipelines)
- Granting service principal Owner role (least-privilege: Contributor on specific RG)
- Secrets in pipeline variables instead of Key Vault-linked variable groups
- No approval gates on production deployments
- Running pipeline agents as root/admin (security risk)
Integration
ado-security-policies — control who can create/modify service connections and pipeline resources
ado-api-cli — automate service connection creation and variable group management
azure-devops-pipelines — YAML authoring that consumes the infrastructure set up here
1---2name: ado-pipelines-ops3description: Use when managing Azure DevOps pipeline infrastructure — self-hosted agent pools, service connections, variable groups, secure files, environments, approvals, and pipeline resource governance.4---56# ADO Pipelines Operations & Infrastructure78## When to Use9- Setting up self-hosted agent pools and registering agents10- Creating and managing service connections (Azure, GitHub, Docker, etc.)11- Managing variable groups and secure files (Library)12- Configuring deployment environments with approvals and checks13- Auditing and governing pipeline resource access1415## Core Jobs1617### 1. Agent Pool Management18```bash19# List agent pools20az pipelines agent pool list --org https://dev.azure.com/MyOrg --output table2122# List agents in pool23az pipelines agent list \24 --pool-id 5 \25 --org https://dev.azure.com/MyOrg \26 --output table27```2829**Self-hosted agent registration:**30```bash31# Download agent, then configure32./config.sh \33 --url https://dev.azure.com/MyOrg \34 --auth pat \35 --token $PAT \36 --pool "SelfHosted-Linux" \37 --agent "agent-01" \38 --unattended3940# Install as service41sudo ./svc.sh install42sudo ./svc.sh start43```4445**Agent pool types:**46- **Microsoft-hosted** — managed, fresh VM per job, no maintenance, costs per parallel job47- **Self-hosted** — your VMs, full control, pre-installed tools, behind firewall access, no per-minute cost48- **Scale set agents** — Azure VMSS auto-scales based on demand (best of both)4950### 2. Service Connections51```bash52# Create Azure Resource Manager service connection53az devops service-endpoint azurerm create \54 --azure-rm-service-principal-id $SP_ID \55 --azure-rm-subscription-id $SUB_ID \56 --azure-rm-subscription-name "Production" \57 --azure-rm-tenant-id $TENANT_ID \58 --name "Azure-Production" \59 --project MyProject6061# List service connections62az devops service-endpoint list --project MyProject --output table63```6465**Service connection types and use cases:**66| Type | Use case |67|------|---------|68| Azure Resource Manager | Deploy to Azure (App Service, AKS, etc.) |69| Docker Registry | Push/pull container images |70| GitHub | Checkout private repos, trigger from GitHub |71| Kubernetes | Deploy to AKS/any cluster |72| Generic | Custom REST APIs, webhooks |7374**Security:** Grant "Project Collection Build Service" only — not broad contributor access.7576### 3. Library — Variable Groups & Secure Files77```bash78# Create variable group79az pipelines variable-group create \80 --name "Production-Config" \81 --variables ENV=prod DB_HOST=prod.db.company.com \82 --project MyProject8384# Add secret variable85az pipelines variable-group variable create \86 --group-id 5 \87 --name "DB_PASSWORD" \88 --value "secret123" \89 --secret true \90 --project MyProject91```9293**Link to Azure Key Vault:**94- Variable group → Link secrets from Azure Key Vault → select secrets95- Requires service connection with Key Vault access96- Secrets auto-refresh on pipeline run9798### 4. Environments & Approvals99```bash100# Create environment101az pipelines environment create \102 --name "production" \103 --project MyProject104```105106**Add approval check via UI:** Environment → Approvals and checks → Add → Approvals107- Set approvers, timeout (default 30 days), instructions108- Allow pipeline to self-approve: disable for prod109110**Environment resources:** VMs and Kubernetes clusters can be registered as resources for deployment target tracking.111112## Key Concepts113- **Agent pool** — collection of agents that can run pipeline jobs114- **Service connection** — authenticated connection to external service (Azure, Docker, GitHub)115- **Variable group** — shared variables across multiple pipelines (vs pipeline-specific variables)116- **Secure file** — binary files (certificates, provisioning profiles) stored encrypted117- **Environment** — logical target (dev/staging/prod) with history, approvals, and resource tracking118- **Scale set agents** — auto-scaling agent pool backed by Azure VMSS119120## Checklist121- [ ] Self-hosted agents using service account (not personal user)?122- [ ] Service connections using service principal (not personal PAT)?123- [ ] Service principal has minimum required permissions only?124- [ ] Secrets in Key Vault-linked variable group (not hardcoded in pipeline)?125- [ ] Production environment has approval gates?126- [ ] Agent capabilities documented (for pool selection in pipeline YAML)?127128## Key Outputs129- Agent pools registered and agents online130- Service connections created with least-privilege service principals131- Variable groups with Key Vault linking for secrets132- Environments with approvals for production133134## Output Format135- 🔴 **Critical** — service connection using personal PAT (breaks on offboarding), no approval on production environment, secrets hardcoded in pipeline YAML136- 🟡 **Warning** — all pipelines using single service connection (no isolation), no environment resource tracking, variable groups without Key Vault137- 🟢 **Suggestion** — use scale set agents for variable workloads, link variable groups to Key Vault, add Exclusive Lock check for sequential deployments138139## Anti-Patterns140- Service connections using personal user credentials (offboarding breaks pipelines)141- Granting service principal Owner role (least-privilege: Contributor on specific RG)142- Secrets in pipeline variables instead of Key Vault-linked variable groups143- No approval gates on production deployments144- Running pipeline agents as root/admin (security risk)145146## Integration147- `ado-security-policies` — control who can create/modify service connections and pipeline resources148- `ado-api-cli` — automate service connection creation and variable group management149- `azure-devops-pipelines` — YAML authoring that consumes the infrastructure set up here