Azure DevOps provides 2 ways to manage CI/CD resources across all projects:

  1. Deployment Groups – A logical grouping of target machines based on environments (Dev, Test, Prod). Agents are installed per environment.

  2. Agent Pools – As the name suggests, this is a pool of build agents, which can be either Microsoft-hosted or self-hosted, that can be used to run builds and releases across multiple projects.

Below is a diagram to illustrate the connections at a high level.

其實嚴格說起來

不管任何的Target在AP或是DG

都具有相同的目標

  • compiling and deploying code to target

只是在使用上有差異而已:

Agent Pool Deployment group
在org底下是共享agent pool的, 亦即不同project可以share相同的AP, 一個mahcine可以裝多個agent來省錢 不共享, 通常一個machine只會裝一台agent到DP中, 通常是拿來做testing or deployment用,比較省錢
** 多一個平行跑的job, 如果是MS-Host/1500 Self-Host/450/月 ** 無論多少個平行跑的job, 皆免費
agent可以自動更新版本 agent也可以更新版本
通常拿來build 或是 簡單的pipeline 不占用大量資源 通常拿來跑各種測試 E2E 負責比較複雜且大量的測試
** pipeline支援yaml 支援agent/serverless/deployment ** 目前不支援yaml (deployment group job) 截至2021/03/29 真der慘 issue on github

假設你只愛託管且不管費用, 請選AP

假設你有很多複雜的行為, 請用DP

Agent pools (either self-hosted or Microsoft-hosted) are easy to manage and use for on-premise and cloud applications. If you’re just starting out on your CI/CD journey, agent pools is the way to go.

However, if you’re a complex organisation with multiple tandem teams using CI/CD, then it makes more sense to compartmentalise and create deployment groups per team with resources specifically allocated to them.

如何安裝azure agent

Microsoft-hosted agents

請直接使用 不用安裝惹

YAML VM Image Label

  • windows-latest OR windows-2019
  • vs2017-win2016
  • ubuntu-latest OR ubuntu-20.04
  • ubuntu-18.04
  • ubuntu-16.04
  • macOS-10.14
  • macOS-latest OR macOS-10.1
jobs:
- job: Linux
  pool:
    vmImage: 'ubuntu-latest'
  steps:
  - script: echo hello from Linux
- job: macOS
  pool:
    vmImage: 'macOS-latest'
  steps:
  - script: echo hello from macOS
- job: Windows
  pool:
    vmImage: 'windows-latest'
  steps:
  - script: echo hello from Windows

Self-hosted Linux agents

prerequisites

  • x64
    -- CentOS 7, 6 (see note 1)
    -- Debian 9
    -- Fedora 30, 29
    -- Linux Mint 18, 17
    -- openSUSE 42.3 or later
    -- Oracle Linux 7
    --Red Hat Enterprise Linux 8, 7, 6 (see note 1)
    -- SUSE Enterprise Linux 12 SP2 or later
    -- Ubuntu 18.04, 16.04
  • ARM32 (see note 2)
    -- Debian 9
    -- Ubuntu 18.04

Download and configure the agent

  1. Log on to the machine using the account for which you've prepared permissions as explained above.
  2. In your web browser, sign in to Azure Pipelines, and navigate to the Agent pools tab:
    • Choose Azure DevOps, Organization settings.
    • Choose Agent pools.
  3. Select the Default pool, select the Agents tab, and choose New agent.
  4. On the Get the agent dialog box, click Linux.
  5. On the left pane, select the specific flavor. We offer x64 or ARM for most Linux distributions. We also offer a specific build for Red Hat Enterprise Linux
  6. On the right pane, click the Download button.
  7. Unpack the agent into the directory of your choice. cd to that directory and run ./config.sh.

Run interactively

./run.sh.

Run once

./run.sh --once.

Run as a systemd service

./svc.sh.

  • If you run your agent as a service, you cannot run the agent service as root user.

還有其它各式各樣的Azure Pipeline Agent

Self-hosted macOS agents

Self-hosted Windows agents

Azure virtual machine scale set agents

self-hosted agent in Docker


你也可以自訂安裝參數

Unattended config (Customize your agent)

提供客製化服務安裝

Required options

  • --unattended agent setup will not prompt for information, and all settings must be provided on the command line
  • --url <url> URL of the server. For example: https://dev.azure.com/myorganization or http://my-azure-devops-server:8080/tfs
  • --auth <type> authentication type. Valid values are:
    • pat (Personal access token)
    • negotiate (Kerberos or NTLM)
    • alt (Basic authentication)
    • integrated (Windows default credentials)

Pool and agent names

  • --pool <pool> pool name for the agent to join
  • --agent <agent> agent name
  • --replace replace the agent in a pool. If another agent is listening by the same name, it will start failing with a conflict

Agent setup

  • --work <workDirectory> work directory where job data is stored. Defaults to _work under the root of the agent directory. The work directory is owned by a given agent and should not share between multiple agents.
  • --acceptTeeEula accept the Team Explorer Everywhere End User License Agreement (macOS and Linux only)
  • --disableloguploads don't stream or send console log output to the server. Instead, you may retrieve them from the agent host's filesystem after the job completes.

Windows-only startup

  • --runAsService configure the agent to run as a Windows service (requires administrator permission)
  • --runAsAutoLogon configure auto-logon and run the agent on startup (requires administrator permission)
  • --windowsLogonAccount <account> used with --runAsService or --runAsAutoLogon to specify the Windows user name in the format domain\userName or userName@domain.com
  • --windowsLogonPassword <password> used with --runAsService or --runAsAutoLogon to specify Windows logon password
  • --overwriteAutoLogon used with --runAsAutoLogon to overwrite the existing auto logon on the machine
  • --noRestart used with --runAsAutoLogon to stop the host from restarting after agent configuration completes

Deployment group only

  • --deploymentGroup configure the agent as a deployment group agent
  • --deploymentGroupName <name> used with --deploymentGroup to specify the deployment group for the agent to join
  • --projectName <name> used with --deploymentGroup to set the project name
  • --addDeploymentGroupTags used with --deploymentGroup to indicate that deployment group tags should be added
  • --deploymentGroupTags <tags> used with --addDeploymentGroupTags to specify the comma separated list of tags for the deployment group agent - for example "web, db"

Diagnostics

./run.sh --diagnostics

Help on other options

./config.sh --help


#azure-devops #azure-pipeline-agent #CICD #deployment-pool #agent-pool #install-az-agent #azure-docker-agent #azure-win-agent #azure-linux-agent #azure-mac-agent







Related Posts

MTR04_0929

MTR04_0929

MTR04_0926

MTR04_0926

[Power BI] 讀書會 #3 Analysis Services 概念(2)

[Power BI] 讀書會 #3 Analysis Services 概念(2)


Comments