⚠️ Update: I experienced some issues running this on a Subscription Plan. Errors included multiple alert messages per trigger, and some few messages being lost. I suspect this to be related to cold starting. I strongly suggest testing it for a certain period of time before going to production, and I would also suggest considering an App Service Plan for the function to run in a dedicated 24/7 VM. Read more here: https://blogs.msdn.microsoft.com/appserviceteam/2018/02/07/understanding-serverless-cold-start/
1. Set up the Teams Connector
First go to the channel in which you want alerts to be posted. There you’ll find the “Connectors” option: From there you’ll be able to configure a new Incoming Webhook. Give it a name and upload an icon (optional). After the creation you will be presented with the URL of the webhook. Remember to copy this URL, as you’ll need it later.
2. Create the Azure Function App
3. Configure the PagerDuty extension
The only remaining step is to set up an extension in PagerDuty from which alerts will be sent when a service triggers an alert. Log on to your company PagerDuty account, go to the Extensions menu (Configuration -> Extensions), and add a new “Generic V2 Webhook” extension, using the function URL as the webhook URL, and map it to a service:
4. Test it!
The integration should now be up an running. Test it by manually creating an incident or by triggering an actual alert from the service. As alerts are being triggered, acknowledged and resolved, messages should appear in your Teams channel: If there’s something you want to change, simply make changes to the code in the Azure Function to better suit your needs. You should be able to add more information about who the incident is assigned to, notes and more. These useful tools will help you get it right:
- The MessageCard Playground helps you design the layout of message cards in Teams (set in the jsonModel variables at the bottom of the function code)
- The PagerDuty webhooks documentation gives you information about the data model used by PagerDuty webhooks
If you come up with a better design layout, or have any other improvements or suggestions, let me know!
❗ Please note: These comments are exports from an older platform, and are no longer active.
Ben Horstmann - Oct 3, 2018
Sindre this is great, thank you for sharing with the community! In your example, do the contents of your ‘Azure Function’ file get pasted into one of the default files (function.json or run.csx)? Or did you create a new index.js file (index.js is not a file in new functions). Thanks again for sharing this with the community and keep up the great work! -Ben from STL
sssss - Jun 3, 2020
I Have changed the card, but the data is not reflecting in my format. where can I update the format.
Luke - May 3, 2019
Is there a way to make this so that replies in teams are added to pagerduty as notes? or to add a acknowledge button in teams?
Gandhi - Jun 1, 2019
So this is 2-way integration? Can we create an issue in pagerduty via ms teams as well?
sindre - Jun 1, 2019
This is a one-way integration for publishing PagerDuty incident updates in a Microsoft Teams channel.
sindre - May 4, 2019
sindre - May 4, 2019
I did make an attempt to set up MessageCards with Acknowledge and Resolve buttons, and got it working, but it was a rather complicated setup with return API calls to the PagerDuty API via additional Azure Functions. I never got it to be as seamless as the Slack bot integration, which is really good. I hope (and expect) PagerDuty to make an official integration similar to the Slack bot at some point. I suspect the only way to make a truly interactive integration with notes and action buttons would be by creating a bot, in which case I think the Microsoft Bot Framework might be a good starting point.