Installing Azure Webhook Infrastructure
- Pooja Gupta (Unlicensed)
- Abirami
Azure webhook infrastructure for high availability of the webhook functionality that means if Insights is down for sometime, payloads from devops tools should not be missed.
Official Link – portal.azure.com
Step - by - step guide on how to Install Azure Webhook Infrastructure
Go to Storage accounts page in the portal or visit link: https://portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.Storage%2FStorageAccounts
Click on + Add Button to add new storage account.
Fill the required details in all the given tabs (Basic, Networking…etc.) and click on Review + create.
Basics
Choose Subscription and Resource Group.
Storage account name: insightswebhookstorage.
Account kind: StorageV2
Leave Replication as it is.
Access Tier: Hot
After clicking create button, a new page will be opened where you can see your storage account deployment. Deployment will take approx. 1 minutes to complete.
After completing deployment, click on Go to Resource button to go inside storage account.
Click on containers tab in the overview section or select from left menu.
Create 3 new containers by click on + container button with names:
insightswebhookevents
insightsfailedwebhookevents
insightsfunctionapp
Select Public access level as Container for all the containers.
Click on 3 dots given on the right side and then click on Access policy to create policy.
Click on + Add Policy button under stored access policy and fill the details to create policy as follows:
Fill Identifier as Insights(You may change)
Select all permissions.
Select start time and end time.
Click OK button.
After clicking OK, Click on Save button to save policy.
Repeat these steps for all containers.
Download the zip file from the nexus repository(PlatformInsightsAzureWebhook.zip) to your local system.
Follow the steps to upload zip file into the container:
Click on functionapp container to go inside container.
Click on upload button.
Select the zip file from the local system.
Select checkbox Overwrite if files already exist.
Click on advanced and change the Blob type to Block Blob and Block size to 100 MB.
Click on Upload button.
Click on the zip filename and copy the URL from the overview section and paste it in notepad.
Click on containers from the left menu and copy the names of the two container i.e. insightswebhookevents and failedwebhookevents and paste it on notepad.
Go to insightswebhookstorage storage account.
Click on Properties under settings in the left menu and copy the value of Primary Blob Service Endpoint and paste it on notepad.
Click on Access Keys under settings in the left menu and copy the value of storage account name and Key of Key1 and paste it on notepad.
Make sure you have 6 values present somewhere as shown in the below image
Go to Function App page from left menu or visit link https://portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.Web%2Fsites/kind/functionapp
Click on + Add button
Fill the required details:
Basics
Choose Subscription and Resource Group.
Function App name: InsightsWebhookHandler
Publish: Code
Runtime stack: Java
Choose Region where your storage account is created.
Monitoring
Select insightswebhookstorage option in Storage account.
Operating System: Windows
Choose Plan type as per needs.
Monitoring
Enable Application Insights: Yes
Application Insights: Create New
Click on Review+ Create button and then review the filled details and click on create.
After clicking create button, a new page will be opened where you can see your function app deployment. Deployment will take approx. 2-3 minutes to complete.
After completing deployment, click on Go to Resource button to go inside function app.
Please reference to the images given below:
Click on configuration under configured features
Click on + New application setting button
Fill the name and values and click OK. Repeat this step for all the values of the table given below and click on Save button.
Copy the values from the notepad we stored before while setting up azure storage.
Note: Please do not change the Application Setting Name while adding application settings.
Name | Value |
---|
Name | Value | |
---|---|---|
1 | WEBSITE_RUN_FROM_PACKAGE | <Zip_URL> |
2 | StorageEndpoint | < Blob Service Endpoint> |
3 | StorageAccountName | < Storage account name> |
4 | StorageAccountKey | < Key> |
5 | WebhookEventContainer | < WebhookEventContainer> |
6 | FailedEventContainer | < FailedEventContainer> |
7 | TimerInterval(Every One Hour) | 0 0 * * * * |
Go to API Management Services from the home page or visit link https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.ApiManagement%2Fservice
Create API management Service. Click on + Add Button.
Fill the required details and click create button.
Click on APIs link from left menu.
Click on +Add API link and click on Function App from the given templates.
Follow the steps to create API:–
Select function app.
Click on browse.
Click on Function App
Select function and click select on right bottom.
Click select on left bottom to return to API configuration page.
Change the API URL suffix to “function”
Click create button.
Click on InsightsWebhookHandler API and then click on POST operation (automatically added) under all operations. After that, Post operation will be shown in the Frontend section.
Click on the highlighted part given in the image.
Click on Query tab and then click on + Add parameter link.
name = endpoint
Type = string
Tick Required checkbox
Click on Save button
Go to Settings tab in the API and unselect Subscription required and click Save button.
Go to API Management Services from the home page or visit link https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.ApiManagement%2Fservice
Open the API management service by clicking on the name. After that, Click on the APIs under API Management from left menu and then click on your Function API(eg - InsightsWebhookHandler)
Click on Setting tab and copy the Base URL. Follow the given steps to complete the API url:
Append the function app name to the Base URL. Example:
https://insightstest.azure-api.net/function/InsightsWebhookHandler
Add query parameter “endpoint” to build the final API URL
https://insightstest.azure-api.net/function/InsightsWebhookHandler? endpoint=<WEBHOOK_NAME>
Replace <WEBHOOK_NAME> with the name of the tool webhook name from the Insights application.
Copy the webhook url provided by Insights Application by clicking on the highlighted part and keep it somewhere in notepad.
Go to Function App page from left menu or visit link https://portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.Web%2Fsites/kind/functionapp
Open the function app by clicking on the name and then click on configuration. After that, Add new application setting by clicking on the + New application setting link
Name: <Webhook Name>
Value: <Webhook URL>
Final step, paste the final API URL in the webhook section of the devops tool(example - github).
©2021 Cognizant, all rights reserved. US Patent 10,410,152