Create an Azure Function to Listen to Blob Created Events

45 minutes
  • 5 Learning Objectives

About this Hands-on Lab

In this hands-on lab, we use the Azure Portal to create an Event Grid-triggered Azure Function that will be invoked when a blob is created in a storage account.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Log In to the Azure Portal

Log in to the Azure Portal using the username and password supplied by the lab.

  1. Open a browser.
  2. Navigate to the provided Azure Portal URL.
  3. Use the supplied username and password to authenticate.
Create the Event Grid-Triggered Function

Starting in the Azure dashboard perform the following tasks:

  1. Open the navigation menu in the upper-left of the Portal.
  2. Click All resources. Wait for all the resources to appear.
  3. In the list, click on the app service that has a name that starts with fa-. This will open the overview page of the function app service.
  4. Click the Functions menu item in the navigation tree on the left of the page.
  5. Click New function near the top center of the page.
  6. From the list of trigger types, select Event Grid Trigger.
  7. In the New Function panel that appears on the right of the page, enter "MyEventGridTriggerFunction" as the name and leave Function as the Authentication level.
  8. Click Create.
  9. Wait for the function to appear.
Create the Event Grid Subscription
  1. Click Add Event Grid subscription.
  2. On the Create Event Subscription form, modify the following fields:
    • Name: blobevent
    • Topic Type: Storage Account
    • Topic Resource: Select the only available storage account
  3. Click Create.
Create a Blob in the Storage Account
  1. Navigate to the storage account in the Azure Portal (select the storage account from all resources).
  2. Click on the Containers link to create a container.
  3. On the containers list page, click + Container.
  4. Name the container "images" and click the OK button to create the container.
  5. Click Upload, select a file, and press the Upload button.
Examine the Function Logs to Verify It Ran

Go back to the Azure function and open the Logs panel. Verify that the function ran and that it wrote an Event Grid event to the log as JSON.

Additional Resources

Your employer needs to process images uploaded to a blob container. You decide to create an Azure Function that is triggered by an Event Grid wired to blob-created events in the storage account. To test the concept, you create the function, configure the Event Grid subscription, and write the event data to the functions log.

What are Hands-on Labs

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?