VSTS Pull Request Alerts in Microsoft Teams

When you start something new, first on your agenda should be a website! Right?

One of the first things Donovan set up for the new "League of Extraordinary Cloud DevOps Advocates" team was a new LoeCDA.com website. The "Tour Dates" section will be extremely useful if you'd like to see any of us at an event near you!

He used the extremely useful yo team yeoman generator and had a new ASP.NET Core website, complete with a CI/CD pipeline, running on docker in Azure in just a few minutes. This still blows my mind, but I digress - that's not the point of this post.

The LoECDA website

Our dev process

Even though this is a very simple website, we agreed to make all changes via pull requests (PRs). This helps us in two ways:

  1. We can exercise the PR process in Team Services and Visual Studio
  2. It helps us learn from each other

Exercising features that real dev teams will be using is really important. Half of the Cloud Dev Advocate role is bringing feedback back to the engineering teams. What better way to do that than using the features?

Learning from each other is an often-overlooked benefit of working with pull requests. It forces code reviews, which is a great way to learn about new techniques or better ways to implement features.

Pull requests for everything

So every change will occur on a feature branch (or topic branch), we'll submit a PR, another team member reviews and approves it, and merges in those changes. Of course once that happens, CI/CD ensures it gets to production with almost no more effort!

Finding out about PRs

We use Microsoft Teams for day-to-day communication, so what better way to learn about new pull requests than through a chat client that's always open?

Teams has a great feature called Connectors, which allows you to integrate with third-party applications. Thankfully, there's a connector for VSTS.

Configuring the VSTS connector

The first (optional) step is to set up a new channel in Teams. You can easily add a connector to an existing channel, but having a specific channel for PRs reduces the noise in your other channels.

To do this, just click on the ellipsis next to your team, and choose Add Channel.

Add Channel

Now click on the ellipsis next to the new channel, and choose Connectors.

Add Connector

Find the Visual Studio Team Services connector. If you already have some VSTS integration, you'll see a Configure button. If not, it will be Add.

Visual Studio Team Services Connector

If you're adding a VSTS connector for the first time, you'll need to walk through the steps to connect to VSTS. Once you've done so, you'll be able to choose your connection (or "Profile") for subsequent VSTS connector configurations.

The next part is easy - just go through the fields and choose the appropriate entries from the dropdowns. You'll need to choose a VSTS Account and Project, and you can choose to be alerted by events for individual VSTS teams, or for all teams.

You'll then be asked for an event type. There are a lot of VSTS events you can choose from here.

PR event type

In our case, we want to hear about both "Pull request created" events, and "Pull request merge commit created" events - i.e. when there's a new PR, and when one has been merged. Unfortunately you can't choose both at the same time, so we had to go through this configuration twice. Not a big deal - it's a once-off configuration and only takes a couple of minutes.

Once done, going back to Connectors (from the channel ellipsis) allows us to see the connectors we've configured.

Configured connectors

The end result

When a new PR is submitted by anyone in the team, there's a new message in the channel - complete with a direct link to view the PR!

New PR

Damian Brady

I'm an Australian developer, speaker, and author specialising in DevOps, developer process, and software architecture. I love Octopus Deploy, Visual Studio Team Services, and reducing process waste.