• Labs icon Lab
  • Cloud
Azure icon
Labs

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.

Azure icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 30m
Published
Clock icon Apr 16, 2025

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. 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.
  2. 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.

  3. 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.
  4. 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.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.