- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud

Using VS Code to Create a Function Triggered by a GitHub Webhook with a Secure Payload
In this hands-on lab, you will learn how to create an Azure Function app, and function using Visual Studio Code. You will store secrets securely using Azure Key vault. Then you will configure the Azure function to retrieve the secrets and use the secret values for verifying incoming Github webhook requests. Then you will configure Github to send webhook requests to the Azure function securely, using a secret. By the end of this lab, you will have a good understanding of how you can securely verify incoming webhook requests from Github using Azure functions.

Lab Info
Table of Contents
-
Challenge
Using Visual Studio code, create and configure an Azure Function with a HTTP trigger that can be called by a GitHub webhook
- Review lab resources
- Connect to the Developer virtual machine using Remote Desktop Protocol (RDP)
- Create an Azure Function App project.
- Create a Function App in Azure.
-
Challenge
Using the Azure Portal and Azure CLI, store and retrieve secrets from Key Vault using Azure Functions
-
Retrieve the function key.
-
Store the Azure Function key in the existing Azure Key vault as a secret. The following code will be used:
RG=$(az group list --query [].name --output tsv) KV=$(az keyvault list --resource-group $RG --query [].name --output tsv) APP=$(az functionapp list --resource-group $RG --query [].name --output tsv) SECRET_URI=$(az keyvault secret list --vault-name $KV --query [].id -o tsv) MI=$(az identity list --resource-group $RG --query [].id -o tsv)
az functionapp update --resource-group $RG --name $APP --set keyVaultReferenceIdentity=${MI}
-
Configure the Function app to retrieve the secret using the existing user-assigned Managed Identity. The following code will be used:
az webapp config appsettings set --resource-group $RG --name $APP --settings GITHUB_WEBHOOK_SECRET="@Microsoft.KeyVault(SecretUri=${SECRET_URI})"
-
Configure the Function app to pass the secret value as an environment variable.
-
-
Challenge
Configure a GitHub webhook that triggers an Azure Function, to integrate GitHub events with Azure functions to securely monitor and respond to repository updates
- Retrieve the Function URL.
- Create a new repository on GitHub.
- Configure a webhook on the GitHub repository.
-
Challenge
Update, deploy, and test an Azure Function to process and verify GitHub webhook payloads securely
- Update and deploy the Function to process the webhook payload and verify the secret.
- Test the function by editing a file in the GitHub repository.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.