They provide a method to allow one application to give real-time information to other applications, thereby establishing a sort of automated conversation between software. Now when you’re preparing for your AZ-400 Designing and Implementing Microsoft DevOps Solutions exam, one of the areas you’ll need to understand is how to configure notifications using these webhooks.
Let’s delve into how to configure webhook notifications in Azure DevOps, a fundamental aspect of understanding for AZ-400.
1. Understanding Webhook Notifications
When an external event occurs, Azure DevOps sends a HTTP POST payload to the webhook’s configured URL – the payload contains information about the event that can be used by the external service to take any relevant further action. Thus, webhooks are useful in situations where you want to notify an external system or service immediately when a specific event occurs in your Azure DevOps project.
Events can range from code pushes, PR events, work item updates, to build and release events. The nature of the event will determine the shape of the payload that is sent.
2. Configuring Webhook Notifications
You’ll first need to navigate to the Service Hooks section in your Azure DevOps project settings. Here’s a step-by-step guide:
- Go to your project in Azure DevOps.
- Click on Project Settings.
- Under Pipelines, click on Service Hooks.
- Click on the + icon to create a new subscription.
- You’ll be greeted with a list of available services, choose ‘Web Hooks’.
- On the next screen, you need to configure the trigger. Choose the type of event that will trigger the webhook.
- After selecting the event type, you will need to customize the filters for the trigger.
- Next, configure the action that Azure DevOps should take once the event is triggered. Depending on the webhook’s action, you would specify the URL.
Example Request
Payload URL: https://your-application.example.com/webhooks
Content type: application/json
Make sure you secure your endpoints as the payload information sent by Azure DevOps, which contains information about the event, can sometimes be sensitive.
You can test the configuration once finished to ensure that Azure DevOps is able to successfully send the HTTP POST request to your external service.
3. An Azure DevOps Webhook Example
An example of where webhook notifications can be valuable is integrating Azure DevOps with Teams. You can configure a webhook that sends an alert to a specific Teams channel whenever a work item is updated in Azure DevOps.
Microsoft provides a connector for Azure DevOps inside Teams. This feature automatically creates a webhook for a specified Teams channel and links it to your Azure DevOps project.
In conclusion, understanding how to configure and apply webhook notifications is crucial for the AZ-400: Designing and Implementing Microsoft DevOps Solutions exam, since efficient communication between software is essential in the DevOps world. By understanding how to configure webhooks, you’ll be able to set up connections between Azure DevOps and other software, allowing for real-time updates and alerts based on the events that are most important to you and your team.
Practice Test
True or False: Webhooks provide a way for notifications to be delivered to a URL when a specified event happens.
- Answer: True
Explanation: Webhooks are designed to send notifications/events to a specified URL when a certain event occurs.
Which of the following can be configured to use webhooks for notification?
- a. Email
- b. Slack
- c. Mobile
- d. Jira
Answer: b, d
Explanation: Webhooks can be used to send notifications to communication platforms such as Slack and project management software like Jira, not to personal emails or mobiles directly.
True or False: It’s possible to use Webhooks to deliver a payload of data based on a specific event in DevOps.
- Answer: True
Explanation: Webhooks are primarily used to deliver a payload of data to a specific URL when a certain event happens in DevOps.
When are webhooks called in the pipeline?
- a. Before the pipeline starts
- b. After the pipeline ends
- c. During the pipeline execution
- d. Anytime
Answer: c
Explanation: Webhooks can be configured to be called during the pipeline execution to notify about various events.
True or False: Webhooks only support GET HTTP method.
- Answer: False
Explanation: Webhooks generally use the POST method to send data to the URL.
Which of the following is not a component of a webhook payload?
- a. Header
- b. Body
- c. Metadata
- d. SSL certificate
Answer: d
Explanation: An SSL certificate is not part of a webhook payload itself. Header, Body, and Metadata are all components of a webhook payload.
True or False: Webhooks can be configured using a scripting language like Python.
- Answer: True
Explanation: Python, like many other languages, can be used to set or create the backend logic needed to accept and process the webhook notifications.
What type of URL do you need to set up a webhook?
- a. FTP
- b. HTTPS
- c. DHCP
- d. DNS
Answer: b
Explanation: You will need a valid HTTPS URL to set up a webhook for sending notifications.
True or False: Each webhook can only be triggered by one specific event.
- Answer: False
Explanation: A single webhook can be configured to trigger based on multiple events.
What should a server do to acknowledge receipt of a webhook payload notification?
- a. Return a 200 OK HTTP status code
- b. Return a 404 Not Found HTTP status code
- c. Send an email confirmation
- d. No action is required
Answer: a
Explanation: To acknowledge receipt of a webhook payload, the server typically needs to return a 200 OK HTTP status code.
Interview Questions
What is a webhook in the context of Azure DevOps?
A webhook is a way for an application to provide real-time information to other applications. In Azure DevOps, webhooks are used to trigger particular processes after certain actions take place.
What is the primary purpose of configuring notifications using webhooks in Azure DevOps?
Configuring notifications using webhooks in Azure DevOps allows real-time interaction and automatic response to events like code pushes and pull requests, thus increasing operational efficiency and productivity.
How can webhooks be secured in Azure DevOps?
Webhooks can be secured in Azure DevOps by implementing Shared Secrets. Shared Secrets, also known as signature, add security in the form of a hashed key to each request for verification purposes.
What is Shared Secrets in the context of Azure DevOps webhooks?
Shared Secrets in Azure DevOps webhooks is a security mechanism to avoid unauthorised notifications. It is a hashed key included in the HTTP header as “X-Signature” that the receiver can use to verify the origin of the notification.
How do you test a webhook in Azure DevOps?
To test a webhook in Azure DevOps, you can use the “Test” button available in the webhook configuration panel. This will send a test ‘ping’ payload to the webhook’s endpoint URL.
In Azure DevOps, can a single project have multiple webhooks?
Yes, in Azure DevOps, you can configure multiple webhooks for a single project. Each webhook can be set to respond to different actions or events.
What happens if the Azure DevOps webhook endpoint URL is not reachable?
If the Azure DevOps webhook endpoint URL is not reachable, Azure DevOps will attempt to deliver the webhook a number of times. If repeated delivery attempts fail, Azure DevOps will deactivate the webhook.
What information is included in the webhook payload in Azure DevOps?
The webhook payload typically contains detailed information about the event that triggered the webhook, such as the type of event, the user who initiated it, and other relevant details.
Can you configure Azure DevOps webhooks to respond to only specific events?
Yes, Azure DevOps webhooks can be tailored to respond to only specific events. These could include events such as pull requests, code pushes, work item updates and build completions.
In what format is the webhook payload sent in Azure DevOps?
Webhook payload in Azure DevOps is sent in JSON format. This allows it to be widely compatible and easily consumable by many different services and applications.
Is it possible to filter events when configuring webhooks in Azure DevOps?
Yes, it is possible to filter events while configuring webhooks in Azure DevOps. These filters can be used to narrow down the conditions under which the webhook will be triggered.
What should be included in a delivery log of a webhook in Azure DevOps?
A delivery log of a webhook in Azure DevOps should include the details of each webhook delivery attempt, the response from the server, and the event that triggered the webhook.
Can webhooks be used in conjunction with Azure Functions?
Yes, webhooks can indeed be used in conjunction with Azure Functions. This allows you to perform complex operations, like running an Azure Function, in response to specific events in Azure DevOps.
What status codes are considered a success when Azure DevOps sends a webhook notification?
HTTP status codes of 200-299 are considered a success when Azure DevOps sends a webhook notification.
What is the retry policy for failed webhook deliveries in Azure DevOps?
If a webhook delivery fails, Azure DevOps will retry delivery every 5 minutes, up to 30 times, or until the delivery succeeds. If delivery continuously fails, Azure DevOps will eventually deactivate the webhook after roughly 3 days.