Webhooks when Serverless Development use, part 1 Azure Function with an http-to set up Trigger
Serverless Computing using Azure Functions offers several advantages, including the use of Webhooks. These allow an analysis of the http calls and the control of the corresponding reactions. In the first part of this workshop, we will create such a function, which can then be used by URL-Trigger triggered.
Is generally understood to be Webhooks user-defined http callbacks. This can be triggered by an event such as, for example, to Update a wiki, or the Transfer of Code to a Repository. The event occurs, configure the source site makes an http request to the URL for the Webhook.
In a DevOps environment, Webhooks are often used to notify an Azure function that, for example, the Code or the configuration for an application on GitHub has changed. The payload of the Webhook sent message contains all relevant Details of the event.
An example: As an IT developer, you would like to, for example, ensure that the chief is informed regularly about the Changes in the company’s own GitHub Wiki; about how frequently the Wiki is changed, which posts are most frequently read, or who writes most of the posts. For this purpose, you can take advantage of the fact that GitHub Webhooks support, i.e. almost any type of event informed.
Combine, we want the GitHub Feature with Azure Functions. We define a logic function to be executed when receiving a Webhook Message. Consequently, our Azure Function then acts as a Listener for all the Wiki-event changes. This four-part Workshop describes the Cause of our Azure function through a Webhook, and then Parse the returned message.
Create the Function App
We start in Azure, we are looking for in the Market Place the term “Function App”. Here we create a simple Function App, in addition to consumption-oriented service plan (Serverless Computing) in our article on serverless deploy an Azure Functions App describe.
Create a Function App in the Portal: the Name of The Function, the App must be unique, in the area of “Hosting” is selected in the service plan.(Image: Three Of A Kind / Microsoft)
As a term we use in this example Node.js. The required resource group and storage account in the same way as the service plan in the section “Hosting” in the course of the Function-App-wizard will be created. As in the case of Web Apps, as well as the Function, the App must have a unique name because of this the Website-the endpoint is generated.
To Add an http Trigger.(Image: Three Of A Kind / Microsoft)
The http Trigger is still missing. To do this, click how to in the section on “functions” on the “add function”, and select it as a template “http trigger”.
The http Trigger generates a default function in the selected Runtime of the matching language.(Image: Three Of A Kind / Microsoft)
The visual representation of the integration possibilities.(Image: Three Of A Kind / Microsoft)
Now we click on “Integration” to be able to Trigger the edit. The Portal shows a beautiful visual representation of the data flow. The user can select from a set of inputs and outputs for its function, including Azure Storage, Cosmos DB, and many other Blob.
The “bindings” our Azure Function “function.json“.(Image: Three Of A Kind / Microsoft)
Then we change the program back to the menu “test” and select the top Drop-Down menu instead of “<Name Functionsapp><Name Trigger>index.js the file “<Name Functionsapp><Name Trigger>function.json from:
The “Binding” means that this feature of http GET and POST requests ….
… is triggered.
The automatically generated Functions-URL to the http Trigger.(Image: Three Of A Kind / Microsoft)
To trigger the function first, as a test, we click on “function-URL” and choose the key is “default”. There is then displayed as shown in the preceding Screenshot, the URL that we want to copy with the Copy button, and then in a new Browser Tab can insert.
Passing parameters in the context of http Events.(Image: Three Of A Kind / Microsoft)
In addition, we can start the API call as a query string with “&name=<string>” any String passed to it. We have verified so successful that we now have a serverless function in Azure, which can be a URL from the “outside” via http trigger.