A little while ago I struggled a bit when I wanted to create an extensible Build Agent setup for an Azure DevOps-project for Business Central. I wanted to use ALOps for this project and different VMs for the Build Agents, depending on different sources (builds based on a Pull Request-policy, builds from dev-branch, builds from release-branch, …), to reduce waiting time. Also the VMs shouldn’t run constantly to avoid heavy Azure-bills.
To get started with this, you need to
- have an active Azure Subscription
- have at least the role “User Access Administrator” in this subscription
- clone/download the repository you can find here
- update the parameters in the “Parameters.ps1”-file of the repository and execute “RunSetup.ps1”
What will happen when I execute this?
So, first of all, you never should just run any (PowerShell-)Scripts you find online 😉 But in this case the script will do the following:
- Create a new Resource Group on Azure (if not existing)
- Create a Variable Group/Library in your Azure DevOps-project
- Create an Agent Pool in your DevOps-organization
- Install the ALOps-Extension from Hodor NV in your DevOps-organization
- Create an agent VM (based on the template from Freddy Kristiansen) (this will contain a Docker container, in which the Build Agent will be installed)
- Create an Azure Storage Table, which will contain Start/Stop-commands for the VMs
- Create an Automation Account, which will handle Starting/Stopping of the VMs
- Create a Runbook for the Automation Account, which will be scheduled to regularly check the status of your VMs
- Create a Webhook to the Runbook; this will be used from inside the Pipeline to start/stop the VMs
You can also find detailed notes (which you should read) in the documentation at the top of RunSetup.ps1. This also contains a section which describes the last steps you’ll need to do manually when the script is done.
Well, I’m not going into too much detail here, because the repository-page and the files themself already contain lots of notes. But if you need assistance in any way, feel free to leave a comment or send me a message on Twitter and I’ll get back to you as soon as possible.