Back in the day I wrote a tool, TFS Alerts DSL, to do Work Item roll-up for TFS. Overtime I updated this to support VSTS (as Azure DevOps was then called), it’s final version is still available in the Azure DevOps Marketplace as the Azure DevOps Service Hooks DSL. So when I recently had a need for Work Item roll-up I did consider using my own tool, just for a short while. However, I quickly realised a much better option was to use the Aggregator CLI. This is a successor to the TFS Aggregator Plug-in and is a far more mature project than my tool and actively under development.
However, I have found the Aggregator CLI a little hard to get started with. The best ‘getting started’ documentation seems to be in the command examples, but I is not that easy to find. So I thought this blog post was a good idea, so I don’t forget the details in the future.
In this latest version of the Aggregator the functionality is delivered using Azure Functions, one per rule. These are linked to Azure DevOps Service hook events. The command line tool setup process configures all of the parts required setting up Azure resources, Azure DevOps events and managing rules.
- Download latest release from https://github.com/tfsaggregator/aggregator-cli/releases, pick the version for the operating system you are planning to use to setup the tool.
- Next you need to setup an Azure App registration for the Aggregator and connect it to a Subscription
- Open the Azure Portal
- Select the Azure Active Directory (AAD) instance to create an App Registration in.
- Create a new App Registration
- Create a new app registration
- Provide name, you can leave the rest as defaults
- Press Register
- From the root of the Azure Portal pick the Subscription you wish to create the Azure Functions in
- In the Access (IAM ) section grant the ‘contributor role’ for the subscription to the newly created App Registration.
Using the Aggregator CLI
At a command prompt we need to now start to use the tool to link up Azure Services and Azure DevOps
- First we log the CLI tool into Azure. You can find the values required from Azure Portal, in the Subscription overview and App Registration overview. You create a password from ‘client and secrets’ section for the App Registration.
.\aggregator-cli.exe logon.azure –subscription <sub-id> –client <client-id> –tenant <tenant-id> –password <pwd>
- Next login to Azure DevOps, create the PAT as detailed in the documentation
.\aggregator-cli.exe logon.ado –url https://dev.azure.com/<org> –mode PAT –token <pat>
- Now we can create the Instance of the Aggregator in Azure
Note: I had ling delays and timeout problems here due to what turned our to be a poor WIFI link. The strange thing was it was not obviously failing WIFI but just unstable enough to cause issues. As soon as I swapped to Ethernet the problems went away.
The basic form of the command is as follows, this will create a new resource group in Azure and then the required Web App, Storage, Application Insights etc. As this is done using an ARM template so it is idempotent i.e. it can re run as many times as you wish, it will just update the Azure services if they already exist.
.\aggregator-cli.exe install.instance –verbose –name yourinstancename –location westeurope
- When this completes, you can see the new resources in the Azure Portal, or check them with command line
- You next need to register your rules. You can register as many as you wish. A few samples are provided in the \test folder in the downloaded ZIP, these are good for a quick tests, thought you will usually create your own for production use. When you add a rule, behind the scenes this creates an Azure Function with the same name as the rule.
.\aggregator-cli.exe add.rule –verbose –instance yourinstancename –name test1 –file test\test1.rule
- Finally you map a rule to some event in Azure DevOps instance
.\aggregator-cli.exe map.rule –verbose –project yourproject –event workitem.updated –instance rfado –rule test1
And once all this done you should have a working system. If you are using the the test rules then quickest option to see it is working is to
- Go into the Azure Portal
- Find the created Resource Group
- Pick the App Service for the Azure Functions
- Pick the Function for the rule under test
- Pick the Monitor
- Pick Logs
- Open Live Metric
- You should see log entries when you perform the event on a work item you mapped to the function.
So I hope this helps my future self remember how get this tool setup quickly