AZ-400: Designing and Implementing Microsoft DevOps Solutions

Configure Collaboration Communication

Demo Notifications from Webhooks

In this tutorial, you’ll learn how to create webhook subscriptions in Azure DevOps to automatically send build notifications to any HTTP endpoint. By the end, you’ll be able to trigger external workflows—such as custom dashboards, chat bots, or monitoring tools—whenever your pipeline completes.

What Is a Webhook?

A webhook is an HTTP callback that enables one application to push real‐time event data to another service. Unlike polling, where you repeatedly check for updates, webhooks deliver payloads instantly when an event occurs.

FeaturePollingWebhook
DeliveryClient-initiated fetchServer pushes data on events
LatencyDependent on polling intervalNear real-time
Resource usageHigher network loadEfficient, event-driven
ConfigurationRequires scheduling logicSimple subscription in UI or API

Scenario

Our project TestWeb hosts an ASP.NET Web API pipeline also named TestWeb. Whenever the pipeline succeeds, we want Azure DevOps to POST a JSON payload to a custom endpoint for further processing.


1. Open Service Hooks

  1. In the lower-left, select Project Settings.
  2. Click Service Hooks.
  3. Choose + Create subscription.

The image shows a web interface for Azure DevOps, specifically the "Service Hooks" settings page, with a dialog box open for selecting a service to integrate with, such as "App Center."

2. Choose the Webhooks Service

  1. Scroll through the service list and select Webhooks.
  2. Click Next.

3. Configure the Trigger

  1. Under Trigger on this type of event, pick Build completed.
  2. For Project, select TestWeb.
  3. Restrict Build status to Succeeded.
  4. Click Next.

The image shows a web interface for configuring service hooks in a project setting, with a focus on setting a trigger for a "Build completed" event.

4. Define the Webhook Endpoint

You can deliver to any HTTP(S) URL—public or private. For this demo, we’ll use RequestBin to capture and inspect the payload.

The image shows a web interface for configuring service hooks in Azure DevOps, with a dialog box open for setting up a new service hook subscription. The dialog includes fields for URL, authentication, and other settings.

OptionDescription
URLEndpoint to receive POST requests
Accept untrusted SSL certificatesAllow self-signed or on-prem certificates (use with caution)
AuthenticationBasic auth credentials (visible to project users)
HTTP HeadersCustom headers (e.g., X-My-Header: value)
Resource detailsLevel of data: None, Minimal, All
Message formatsPayload formats: Text, HTML, Markdown

Warning

Enabling Accept untrusted SSL certificates is not recommended for public endpoints.

Once you enter your RequestBin URL and settings, click Test.

curl -d '{ "name": "Yoda" }' \
     -H "Content-Type: application/json" \
     https://enkmx78wgdqmb.x.pipedream.net/

The image shows a web interface for configuring a new service hook subscription in Azure DevOps, with options to post events via HTTP to a specified URL. The settings include fields for URL, SSL certificate acceptance, and basic authentication credentials.

A successful test displays a green checkmark:

The image shows a web interface for Azure DevOps, specifically the "Service Hooks" settings page, with a notification indicating a successful test of a web hook.


5. Inspect the Sample Payload

Choose All for resource details and message formats to see everything Azure DevOps sends:

{
  "root": {
    "subscriptionId": "00000000-0000-0000-0000-000000000000",
    "notificationId": 7,
    "eventType": "build.complete",
    "message": {
      "text": "Build 20150407.2 succeeded",
      "html": "Build <a href=\"https://fabrikam-fiber-inc.visualstudio.com/...\">20150407.2</a>",
      "markdown": "Build [20150407.2](https://fabrikam-fiber-inc.visualstudio.com/...)"
    },
    "resource": {
      "id": 1,
      "buildNumber": "20150407.2",
      "status": "completed",
      "result": "succeeded",
      "definition": {
        "id": 1,
        "name": "CustomerAddressModule"
      }
    }
  }
}

Click Finish to save your subscription.

The image shows a web interface for Azure DevOps, specifically the "Service Hooks" settings page, displaying a configured webhook for a project.

Testing the Webhook in Real Time

  1. Go to Pipelines > TestWeb.
  2. Click Run pipeline (or Queue).
  3. After it succeeds, refresh your RequestBin URL to view the new POST payload.

Example of a real‐time payload:

{
  "root": {
    "notificationId": 7,
    "eventType": "build_complete",
    "message": {
      "text": "Build 20150407.2 succeeded"
    },
    "resource": {
      "id": 1,
      "status": "completed",
      "result": "succeeded"
    }
  }
}

In your pipeline logs, you’ll see:

Job
  Pool: KodeKloudCustomer
  Image: windows-latest
  Agent: KodeKloudAgent1
  Started: Just now
  Duration: 22s

Editing or Creating Additional Subscriptions

Return to Project Settings > Service Hooks at any time to:

  • Modify existing webhooks (e.g., trigger on pull requests).
  • Add integrations for Microsoft Teams, Slack, Trello, and more.
  • Build multiple subscriptions for custom apps.

The image shows a settings page for service hooks in Azure DevOps, with a dialog box open for selecting a trigger event, such as "Pull request commented on."

Webhooks in Azure DevOps unlock powerful automation scenarios—experiment with different event types and endpoints to streamline your CI/CD workflows.

Watch Video

Watch video content

Previous
Demo Creating a Dashboard