Configure a Webhook in Microsoft Azure

In the world of Azure, a Webhook is a trigger. There are several systems in Azure that can be triggered, including:

  • Runbooks in Azure Automation

  • Web jobs in Web Apps or Service Fabric that allow a website to have a background task

  • Functions, another Service Fabric feature but is a server-less method of running a task or small workflow

One of the scenarios that you will be most familiar with is runbooks in Azure Automation. Automation allows us to create a runbook, which will perform some task, such as powering up one or more virtual machines. That runbook can be triggered or started in many ways, one of the methods is triggering via a webhook.

We can create a webhook in the Azure Portal or a runbook. This webhook generates a URI, a uniform resource identifier that looks like a URL. We can use this URI in any external system to start the runbook via HTTP POST action.

For example: A developer writes an application that is running in Azure or anywhere with Internet access and when something happens, the URI is posted. Azure Automation will respond by executing the associated runbook.

Create a Webhook API token from ARM

  1. Login into ARM

  2. Click on Admin Section -> API Token

  3. Click on Create API Token.

  1. Enter the token name

  2. Select Type as “webhook”

  3. Enter Description if required

  4. Click on Create Option

  1. Your New API Token is created

Create webhook with authentication on Azure

1. Log into Microsoft Azure Account at https://portal.azure.com/.

2. Go to your project Service Hooks page:

https://{orgName}/{projectname}/settings/serviceHooks

3. Click on Create Subscription.

4. The wizard will start and give a list of all the services for which integration is to be created.

5. Click on Next and we will see a list of triggers when an event occurs. Select the event to trigger on and any filters (if applicable):

6. The next step is to provide the payload URL. The payload URL is the URL of the server that will receive the webhook POST requests. Paste the copied URL generated by AutoRABIT or enter the payload URL manually.

Payload URL: < instance_url>/api/webhook/v2/<orgname>/trigger-scm-push-request

For example: If the instance is https://login.autorabit.com, then the payload URL would be:

https://login.autorabit.com/autorabitrest/webhook/triggerSCMPushrequest

7. Add the basic authentication details as below

Basic authentication username: ARM login username

Basic authentication password: Webhook type API token generated from ARM

Enter the Username used in Autorabit and password as webhook API Token generated in ARM.

NOTE: If any type of trigger event, such as Pull Request and Pull Request updated, is required, use the same hook configuration with the above URL and respective authentication details."

8. confirm the settings are correct, test the subscription and then finish the wizard.

  1. Click on the Finish button to complete the service hook subscription. The webhook can be seen in the Service Hooks tab.

  1. Once the build is triggered via webhook and completed successfully, refresh the service hook tab to find out that the webhook succeeded. We can also view the history of webhooks to see how many times the event was triggered and if the webhook was completed successfully or not.

For Enterprise customers:

/api/webhook/v2/<orgname>/enterprise/trigger-scm-push-request

/api/webhook/v2/<orgname>/enterprise/sync-alm-commits

Last updated