You are on page 1of 8

Contents

Set up a local deployment for an Azure build application....................................................................2


Configure a local agent............................................................................................................................2
Prerequisites........................................................................................................................................2
Prepare permissions............................................................................................................................2
Authenticate with a personal access token (PAT)................................................................................2
Confirm the user has permission.........................................................................................................3
Download and configure the agent.....................................................................................................4
Run the agent......................................................................................................................................5
Set up a local deployment for an Azure build application

Configure a local agent


Prerequisites
Make sure your machine has these prerequisites:

 Windows 7, 8.1, or 10 (if using a client OS)


 Windows 2008 R2 SP1 or higher (if using a server OS)
 PowerShell 3.0 or higher
 .NET Framework 4.6.2 or higher

Prepare permissions
Decide which user you'll use

As a one-time step, you must register the agent. Someone with permission to administer the agent
queue1 must complete these steps. The agent will not use this person's credentials in everyday
operation, but they're required to complete registration. Learn more about how agents communicate2.
1
reference: https://docs.microsoft.com/en-us/azure/devops/organizations/security/about-security-
roles?view=azure-devops#agent-queue-security-roles
2
reference: https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-
devops&tabs=browser#communication

Authenticate with a personal access token (PAT)


1. Sign in with the user account you plan to use in your Azure DevOps organization
(https://dev.azure.com/{your_organization}).
2. From your home page, click User setting icon > Personal access tokens.
3. Create a personal access token. For the scope select Agent Pools (read, manage) and make sure
all the other boxes are cleared. If it's a deployment group agent, for the scope select
Deployment group (read, manage) and make sure all the other boxes are cleared. Select Show
all scopes at the bottom of the Create a new personal access token window to see the complete
list of scopes.

4. Copy the token. You'll use this token when you configure the agent.

Confirm the user has permission


Make sure the user account that you're going to use has permission to register the agent. Is the user an
Azure DevOps organization owner or TFS or Azure DevOps Server administrator? Stop here, you have
permission.
Otherwise:

1. Open a browser and navigate to the Agent pools tab for your Azure Pipelines organization or
Azure DevOps Server or TFS server:
a. Choose Azure DevOps, Organization settings.

b. Choose agent pools.

2. Click the pool on the left side of the page and then click Security.
3. If the user account you're going to use is not shown, then get an administrator to add it. The
administrator can be an agent pool administrator, an Azure DevOps organization owner, or a
TFS or Azure DevOps Server administrator.

If it's a deployment group agent, the administrator can be an deployment group


administrator, an Azure DevOps organization owner, or a TFS or Azure DevOps Server
administrator.

You can add a user to the deployment group administrator role in the Security tab on the
Deployment Groups page in Azure Pipelines.

Note
If you see a message like this: Sorry, we couldn't add the identity. Please try a different identity.,
you probably followed the above steps for an organization owner or TFS or Azure DevOps Server
administrator. You don't need to do anything; you already have permission to administer the
agent queue.

Download and configure the agent


Azure Pipelines

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:
a. Choose Azure DevOps, Organization settings.

b. Choose Agent pools.

3. Select the Default pool, select the Agents tab, and choose New agent.
4. On the Get the agent dialog box, choose Windows.
5. On the left pane, select the processor architecture of the installed Windows OS version on your
machine. The x64 agent version is intended for 64-bit Windows, whereas the x86 version is
intended for 32-bit Windows. If you aren't sure which version of Windows is installed, follow
these instructions to find out.
6. On the right pane, click the Download button.
7. Follow the instructions on the page to download the agent.
8. Unpack the agent into the directory of your choice. Then run config.cmd. This will ask you a
series of questions to configure the agent.

Note
We strongly recommend you configure the agent from an elevated PowerShell window. If you
want to configure as a service, this is required.

Server URL and authentication

When setup asks for your server URL, for Azure DevOps Services, answer https://dev.azure.com/{your-
organization}.

When setup asks for your authentication type, choose PAT. Then paste the PAT token you created into
the command prompt window.

Note

When using PAT as the authentication method, the PAT token is only used during the initial
configuration of the agent. Later, if the PAT expires or needs to be renewed, no further changes
are required by the agent.

Choose interactive or service mode

For guidance on whether to run the agent in interactive mode or as a service, see Agents: Interactive vs.
service.

If you choose to run as a service (which we recommend), the username you run as should be 20
characters or less.

Run the agent


Run interactively

If you configured the agent to run interactively, to run it:

PowerShell command:

.\run.cmd

To restart the agent, press Ctrl+C to stop the agent and then run run.cmd to restart it.

Run once

For agents configured to run interactively, you can choose to have the agent accept only one job. To run
in this configuration:

PowerShell command:

.\run.cmd --once

Agents in this mode will accept only one job and then spin down gracefully (useful for running on a
service like Azure Container Instances).
The result should look somewhat like this:

To control this agent you can choose to install it as a service on Windows or you can choose to run the
agent from the command line. To start and stop the agent I added two scripts:

Start.cmd:

Start.cmd:

cd c:

cd \EK-VSTS-Agent

start “EK-VSTS Azure agent” .\run.cmd

exit

Stop.cmd:

taskkill /FI “WindowTitle eq EK-VSTS Azure agent*” /T /F


Setup a build and release pipeline in Azure
Goto Pipelines in your Azure Devops project and click on new pipeline. My example uses a project
named OracleConnectionApp.

*Important note: This solution will only work when you do NOT have a .gitignore file in your repository*

1. Under Projects, select OracleConnectionApp.

2. Under Pipelines, click Builds tab. Click the New pipeline button.

You might also like