0
0
Azurecloud~30 mins

Event Grid for event routing in Azure - Mini Project: Build & Apply

Choose your learning style9 modes available
Event Grid for event routing
📖 Scenario: You are setting up a simple event routing system in Azure using Event Grid. This system will route events from a storage account to a function app that processes these events.
🎯 Goal: Build an Azure Event Grid subscription that routes events from a storage account to an Azure Function endpoint.
📋 What You'll Learn
Create a resource group variable with the exact name resource_group set to myResourceGroup.
Create a storage account variable with the exact name storage_account set to mystorageacct.
Create an Event Grid subscription variable with the exact name event_subscription set to myeventsubscription.
Create an endpoint variable with the exact name endpoint_url set to https://myfunctionapp.azurewebsites.net/runtime/webhooks/eventgrid?functionName=ProcessEvent.
Create an Event Grid subscription resource that connects the storage account to the endpoint.
💡 Why This Matters
🌍 Real World
Event Grid is used to route events from Azure resources to various endpoints for processing, enabling reactive and serverless architectures.
💼 Career
Understanding Event Grid subscription configuration is essential for cloud engineers and developers working with event-driven Azure solutions.
Progress0 / 4 steps
1
DATA SETUP: Define resource group and storage account variables
Create a variable called resource_group and set it to myResourceGroup. Then create a variable called storage_account and set it to mystorageacct.
Azure
Need a hint?

Use simple string variables to hold the resource group and storage account names.

2
CONFIGURATION: Define event subscription and endpoint URL variables
Create a variable called event_subscription and set it to myeventsubscription. Also create a variable called endpoint_url and set it to https://myfunctionapp.azurewebsites.net/runtime/webhooks/eventgrid?functionName=ProcessEvent.
Azure
Need a hint?

Use string variables for the event subscription name and the function app endpoint URL.

3
CORE LOGIC: Create the Event Grid subscription resource configuration
Create a dictionary called event_grid_subscription with keys name, scope, and destination. Set name to event_subscription. Set scope to the storage account resource ID string in the format /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/{resource_group}/providers/Microsoft.Storage/storageAccounts/{storage_account}. Set destination to a dictionary with key endpointType set to WebHook and key properties set to a dictionary with key endpointUrl set to endpoint_url.
Azure
Need a hint?

Use an f-string to build the scope string with the resource group and storage account variables.

4
COMPLETION: Add the event subscription filter to only include Microsoft.Storage.BlobCreated events
Add a key filter to the event_grid_subscription dictionary. Set it to a dictionary with key includedEventTypes set to a list containing the string Microsoft.Storage.BlobCreated.
Azure
Need a hint?

Add the filter key at the same level as destination inside the event_grid_subscription dictionary.