This scripts configures a Windows Server Core based container with Azure DevOps agent, Terraform, json2hcl, the selected PowerShell modules and installs and configures the Visual Studio Team Services build agent on it.
This scripts downloads and installs the latest available version of the Azure DevOps agent, and registers the instance(s) to the selected Agent Pool. It also configures a Windows Server Core based container (with the latest version of the microsoft/windowsservercore LTSC image available on Docker Hub), with the latest version of Terraform, json2hcl and the selected PowerShell modules (by default Az, AzureAD, Pester). This container is intended to be run as an Azure Container Instance.
After the successful configuration, it prints the available disk space and keeps periodically checking that the "vstsagent" service is in a running state. The Container's running state is determined by vstsagent service state. Failure of the service will cause the Container instance to be re-initialized. If this happens and the PAT token is still valid, the container will auto-heal itself. If the PAT token has been revoked by this time, the container creation will fail.
VSTSAccountName
: Name of the Azure DevOps account - formerly Visual Studio Team Services (VSTS) account, e.g.https://<Azure DevOps Account Name>.visualstudio.com
- OR -https://dev.azure.com/<Azure DevOps Account Name>/
PATToken
: PAT token generated by the user who is configuring the container to be used by VSTS.AgentNamePrefix
: Prefix of the name of the agent shown on the Azure DevOps (VSTS) portal.PoolName
: Name of the Agent pool. It defaults to the "Default" pool when not defined.RequiredPowerShellModules
: List of the required PowerShell modules, e.g. Az, AzureAD, PesterInstallAzureCli
: Switch to define whether or not you want to install the Azure CLI on your container.InstallPowerShellCore
: Switch to define whether or not you want to install Azure PowerShell Core on your container.UseChocolatey
: Switch to define whether or not Chocolatey should be used to install the supported components
.\Install-VstsAgentWindowsServerCoreContainer.ps1 -VSTSAccountName "<Azure DevOps account Name>" -PATToken "<PAT Token value>"
This installs all the components with the default configuration (Default Agent Pool, "Az", "AzureAD", "Pester" PowerShell modules, randomly generated agent name).
.\Install-VstsAgentWindowsServerCoreContainer.ps1 -VSTSAccountName "<Azure DevOps account Name>" -PATToken "<PAT Token value>" -AgentNamePrefix "<prefix of the Azure DevOps agent's name>" -PoolName "CoreContainers"
This installs all the components with the defined Agent name, and Pool name, with the default PowerShell modules.
.\Install-VstsAgentWindowsServerCoreContainer.ps1 -VSTSAccountName "<Azure DevOps account Name>" -PATToken "<PAT Token value>" -AgentNamePrefix "<prefix of the Azure DevOps agent's name>" -PoolName "CoreContainers" -RequiredPowerShellModules "Az", "AzureAD", "Pester"
This installs all the components with the defined Agent name, Pool name, and PowerShell modules.
<none>
<none>
- Version: 1.0
- Author: Mate Barabas, Andrew Auret
- Creation Date: 2018-08-23
- References: The Install-VstsAgent function is a slightly modified version of the provisioning script available as part of Azure DevTest Labs (available in August 2018).