如何在Azure DevOps中实现评论更新时触发Webhook
Great question! I’ve dealt with this exact issue before—Azure DevOps (ADO) doesn’t trigger work item save events when you edit a comment, so your existing webhook misses those updates entirely. Here are four actionable solutions to get your sync working for comment edits:
1. Poll for Comment Changes via ADO REST API
Instead of relying on passive webhooks, actively check for updated comments on a schedule:
- Use ADO’s Work Item Comments endpoint:
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{id}/comments?api-version=7.1-preview.3to fetch all comments for a bug, including theirlastUpdatedDateand revision details. - Maintain a log of comment states in your support tool (store the latest update time or revision ID for each comment).
- Set up a scheduled task (like a cron job or Azure Logic App) to run this API call at regular intervals. Compare the fresh data with your log—if you detect an edited comment, trigger your sync logic to update your support tool.
- Pros: Simple to implement, no changes needed to ADO’s core behavior. Cons: Has minor latency based on your poll frequency.
2. Use Azure Functions + ADO Graph API Event Subscriptions
ADO supports granular event subscriptions that can catch comment edits directly:
- Build an Azure Function with an HTTP trigger to act as your event receiver.
- Use ADO’s Graph API to create a subscription for the
WorkItemCommentUpdatedevent type. Point this subscription to your Azure Function endpoint. - When a comment is edited, ADO will push a real-time event to your function. You can then process this event to sync the updated comment back to your support tool.
- Pros: Real-time triggering, no polling latency. Cons: Requires setting up Azure Functions and configuring ADO event subscriptions.
3. Build a Custom ADO Extension to Force Work Item Save
If your team has ADO customization permissions, you can tweak the comment edit flow:
- Develop a lightweight ADO extension that modifies the comment edit save button. Add logic to automatically trigger a work item save after the comment is edited (using ADO’s Work Item Update API).
- This way, the work item save event fires, and your existing webhook will catch the change. You can then update your support tool with the edited comment from the work item’s revision history.
- Pros: Reuses your existing webhook infrastructure. Cons: Requires development and maintenance of an ADO extension.
4. Adjust Webhook Trigger Conditions to Target Work Item Revisions
Every comment edit increments the work item’s System.Revision value—you can leverage this to trigger your webhook:
- Update your existing webhook to listen for Work Item Updated events, with a filter condition:
System.Revision > [previous revision number](you’ll need to track the last revision for each bug in your support tool). - When your webhook triggers, check the work item’s revision history to see if the change was a comment edit (look for updates to the
Commentfield). If so, sync the edited comment to your support tool. - Pros: Works with your existing webhook setup. Cons: Requires adding logic to filter out non-comment revisions.
You can also combine any of these with your existing tag-based triggering logic—just add a check that the bug has your target tag before running the sync.
内容的提问来源于stack exchange,提问作者Jack Handy

