Skip to main content

Create an Azure Function to Listen to Blob Created Events

Hands-On Lab

 

Photo of

Training Architect

Length

00:45:00

Difficulty

Intermediate

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.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Create an Azure Function to Listen to Blob Created Events

Introduction

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.

Scenario

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.

Log In to the Azure Portal

  1. Log in to the Azure Portal using the credentials provided on the lab instructions page.

Create the Event Grid-Triggered Function

  1. Open the menu in the top-left corner and select All resources.

  2. Click on the app service starting with fa-.

  3. In the left-hand pane, select the Functions row.

  4. Click + New function.

  5. Select the Azure Event Grid trigger box from the list.

  6. Enter "MyEventGridTrigger" without quotes in the Name box.

  7. Click Create.

Create the Event Grid Subscription

  1. Click Add Event Grid subscription.

  2. In the Name box, enter "blobevent" without quotes.

  3. Use the Topic Types combo box to select Storage Accounts.

  4. Click the Subscription combo box and select the only available option.

  5. Click the Resource Group combo box and select the only available option.

  6. Click the Resource combo box and select the only available option.

  7. Click Create.

Create a Blob in the Storage Account

  1. At the top of the window, right-click on All resources and open it in a new tab.

  2. Navigate to the new tab.

  3. Click on the storage account.

  4. In the main pane, click Containers.

  5. Click + Container.

  6. Enter a Name of "images" without quotes in the box provided.

  7. Click OK.

  8. Click the images row.

  9. Click Upload.

  1. Click the folder button to open the file browser.

  2. Select a local file and then click Open. It is recommended to use a small file.

  3. Click Upload.

Examine the Function Logs to Verify It Ran

  1. Return to the Event Grid trigger tab and verify the logs.

Conclusion

Congratulations, you've completed this hands-on lab!