Skip to content

Instantly share code, notes, and snippets.

@JasonFreeberg
Last active December 9, 2020 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JasonFreeberg/c860df6e1aa0fe423cba86e94577adab to your computer and use it in GitHub Desktop.
Save JasonFreeberg/c860df6e1aa0fe423cba86e94577adab to your computer and use it in GitHub Desktop.
Azure DevOps self hosted VM
#!/bin/bash
agentuser=${AGENT_USER}
pool=${AGENT_POOL}
pat=${AGENT_TOKEN}
azdourl=${AZDO_URL}
# install az cli
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# download azdo agent
mkdir -p /opt/azdo && cd /opt/azdo
cd /opt/azdo
curl -o azdoagent.tar.gz https://vstsagentpackage.azureedge.net/agent/2.179.0/vsts-agent-linux-x64-2.179.0.tar.gz # Newer versions may be available at the time you're reading this
tar xzvf azdoagent.tar.gz
rm -f azdoagent.tar.gz
# configure as azdouser
chown -R $agentuser /opt/azdo
chmod -R 755 /opt/azdo
runuser -l $agentuser -c "/opt/azdo/config.sh --unattended --url $azdourl --auth pat --token $pat --pool $pool --acceptTeeEula"
# install and start the service
./svc.sh install
./svc.sh start
az vm extension set \
--resource-group myResourceGroup \
--vm-name myVM \
--name customScript \
--publisher Microsoft.Azure.Extensions \
--settings '{"fileUris": ["extension-script.sh"],"commandToExecute": "./hello.sh"}' \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment