Creating a JavaScript function triggered by a Webhook
Let's create a JavaScript function in Microsoft Azure using Azure Portal:
- Log in to the Azure portal and navigate to the function app, which we created in the previous chapter.
- Click on the
+
sign to add a new Azure Function. Set the language asJavascript
and the template asGeneric Webhook
, as shown in the following screenshot:
![](https://static.packt-cdn.com/products/9781787122932/graphics/e1748879-fafc-4982-981a-4685c262cb15.png)
- Now provide a name for the function and click on
Create
:
![](https://static.packt-cdn.com/products/9781787122932/graphics/0bd195c7-2c6b-4fd3-973d-aedee414b46d.png)
- A default template will be created, as shown in the following screenshot:
![](https://static.packt-cdn.com/products/9781787122932/graphics/612e6533-ac33-4e4f-b97b-4a30aec080d3.png)
- Get the function URL and copy it. We will use it later in the chapter. Save it in a notepad:
![](https://static.packt-cdn.com/products/9781787122932/graphics/8cb35078-f20b-472c-8173-55c76e9a50e9.png)
- Now, we will create a Webhook endpoint in an activity log alert in Azure Monitor. Click on
Monitor
, as shown in the following screenshot:
![](https://static.packt-cdn.com/products/9781787122932/graphics/dee8f0da-add2-4936-9508-339439e6a0b1.png)
- Now we need to create an alert. Click on
Alerts
and then onAdd activity log alert
:
![](https://static.packt-cdn.com/products/9781787122932/graphics/a2ffe278-6ec7-4d71-b5f7-b77f83177a99.png)
- Provide the following details:
![](https://static.packt-cdn.com/products/9781787122932/graphics/f3d373a4-a2ae-4bb4-8539-134e9fd7e60f.png)
- Here's a description of the terms in the preceding screenshot:
- *
Activity log alert name
: Name of the activity log alert. - *
Subscription
: Microsoft Azure...
- *