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.
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.
- Open a browser.
- Navigate to the provided Azure Portal URL.
- Use the supplied username and password to authenticate.
- Create the Event Grid-Triggered Function
Starting in the Azure dashboard perform the following tasks:
- Open the navigation menu in the upper-left of the Portal.
- Click All resources. Wait for all the resources to appear.
- 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.
- Click the Functions menu item in the navigation tree on the left of the page.
- Click New function near the top center of the page.
- From the list of trigger types, select Event Grid Trigger.
- 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.
- Click Create.
- Wait for the function to appear.
- Create the Event Grid Subscription
- Click Add Event Grid subscription.
- On the Create Event Subscription form, modify the following fields:
- Name: blobevent
- Topic Type: Storage Account
- Topic Resource: Select the only available storage account
- Click Create.
- Create a Blob in the Storage Account
- Navigate to the storage account in the Azure Portal (select the storage account from all resources).
- Click on the Containers link to create a container.
- On the containers list page, click + Container.
- Name the container "images" and click the OK button to create the container.
- 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.