Integrating Systems with Webhooks and Service Hooks
This lesson explains event delivery, how to secure it, and how to make a receiver reliable.
Learning outcomes
After completing this lesson, you will be able to:
- Explain why events are preferred to polling.
- Verify a GitHub webhook signature.
- Describe service hook publishers, consumers and actions.
- Design a reliable receiver.
Why events are better than polling
One system can learn about changes in another in two ways. With polling, it asks repeatedly whether anything has changed, which wastes requests and introduces delay. With an event, the source sends a message when something happens, so the receiver reacts immediately and does no work when nothing has changed. A webhook is the simplest form of event delivery: an HTTP POST request sent to a URL you control.
GitHub webhooks
A GitHub webhook is configured on a repository, on an organization or in a GitHub App. It has a payload URL, a content type, optional secret, and a list of subscribed events, such as push, pull_request or workflow_run. Subscribing only to what is needed reduces load on the receiver. Each delivery is logged in the settings, and failed deliveries can be redelivered manually.
Verifying the sender
A payload URL is reachable by anyone who knows it, so a receiver must verify that each request truly came from GitHub. When a secret is configured, GitHub calculates an HMAC SHA-256 hash of the payload with the secret and sends it in the X-Hub-Signature-256 header. The receiver computes the same hash and compares the two with a constant-time comparison. The following Python function shows the logic.
import hashlib, hmac
def is_genuine(secret: bytes, payload: bytes, signature_header: str) -> bool:
expected = "sha256=" + hmac.new(secret, payload, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature_header)Designing a reliable receiver
GitHub expects a quick response, and it treats a slow reply as a failed delivery. A receiver should validate the request, place the work on a queue, and respond immediately with a 2xx status. A background worker then does the processing. The X-GitHub-Delivery header provides a unique identifier, which lets a receiver ignore a duplicate if the same delivery arrives again.
A webhook check that can be fooled
Azure DevOps service hooks
In Azure DevOps, service hooks provide event delivery. A subscription connects a publisher, which is the Azure DevOps service raising the event, with a consumer, which is the receiving service, and an action. For example, a subscription might send Build completed events, filtered to one pipeline, to a generic webhook.
The generic Web Hooks consumer posts JSON to a URL, with optional basic authentication and custom headers, and built-in consumers include Azure Service Bus and Azure Storage Queues. Subscriptions are created in Project settings > Service hooks, and by default project administrators have the permission to create and view them. Azure DevOps service traffic reaches a private receiver only if the firewall allows it, so inbound rules may need the Azure DevOps IP ranges.
Sending events to Azure Service Bus or Azure Storage Queues is a sound design for reliability, as the queue absorbs bursts and holds messages if the processing system is down.
The following table summarizes the difference in vocabulary.
| Aspect | GitHub | Azure DevOps |
|---|---|---|
| Name | Webhook | Service hook subscription |
| Scope | Repository, organization or app | Project |
| Authenticity | HMAC signature with a shared secret | Basic authentication or custom headers |
| Targets | Any HTTPS URL | Web Hooks and built-in consumers |
The following diagram follows a failed production run's event to a service desk ticket without losing events.

Service hook subscriptions
Inbound events to a pipeline
The reverse direction, in which an external event starts a pipeline, is also possible. GitHub Actions has the repository_dispatch event, which an external system triggers through the REST API, and workflow_dispatch for manual runs with inputs. Azure Pipelines can define an incoming webhook service connection, and reference it as a webhook resource in YAML, so that a post to that endpoint starts a run.
Starting a pipeline from outside
Creating tickets from failures
When a production pipeline fails in Azure Pipelines, a ticket must be created in a third-party service desk that has an HTTP API. Occasional outages of the service desk must not lose events. What should you design?
You should create a service hook subscription for failed runs of that pipeline, delivering to Azure Service Bus, with an Azure Function that reads the queue and calls the service desk API. If the service desk is unavailable, messages stay in the queue and are retried. A direct Web Hooks subscription to the service desk would fail for events raised during an outage, and a script polling the pipeline API would add delay and maintenance.
Why should a webhook receiver respond quickly and process later?
Show answer
GitHub treats a slow response as a failed delivery. Queuing the work lets the receiver acknowledge at once, and absorbs bursts.
Exam Tips
Remember for the exam
- A GitHub webhook secret produces the X-Hub-Signature-256 header.
- Acknowledge quickly with a 2xx response, and do the work on a queue.
- A service hook subscription links a publisher event to a consumer action.
- Azure Service Bus as a consumer protects against receiver outages.
- repository_dispatch lets an external system start a GitHub workflow.