Bird
Raised Fist0
Azurecloud~10 mins

Event Grid for event routing in Azure - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Process Flow - Event Grid for event routing
Event Source emits event
Event Grid receives event
Event Grid matches event to subscriptions
Event Grid routes event to subscribers
Subscribers receive and process event
Events are sent from a source to Event Grid, which then routes them to the right subscribers based on subscriptions.
Execution Sample
Azure
1. Event Source sends event
2. Event Grid receives event
3. Event Grid checks subscriptions
4. Event Grid routes event
5. Subscriber processes event
This sequence shows how an event flows from the source through Event Grid to subscribers.
Process Table
StepActionEvent Grid StateRouting DecisionSubscriber Action
1Event Source emits eventWaiting for eventNo routing yetNo action
2Event Grid receives eventEvent receivedCheck subscriptionsNo action
3Event Grid matches event to subscriptionsEvent matchedRoute to subscriber A and BNo action
4Event Grid routes eventRouting in progressSend event to subscriber A and BNo action
5Subscribers receive eventEvent deliveredRouting completeSubscriber A and B process event
6EndIdleNo routingWaiting for next event
💡 Event delivered to all matching subscribers; routing complete.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 5Final
Event Grid StateWaiting for eventEvent receivedEvent matchedRouting in progressEvent deliveredIdle
Routing DecisionNoneNoneRoute to subscriber A and BSend event to subscribersRouting completeNone
Subscriber ActionNoneNoneNoneNoneProcess eventWaiting
Key Moments - 3 Insights
Why does Event Grid check subscriptions after receiving an event?
Event Grid needs to know which subscribers want this event type to route it correctly, as shown in step 3 of the execution_table.
What happens if no subscriptions match the event?
Event Grid will not route the event to any subscriber, so no subscriber action occurs. This is implied by the routing decision in step 3.
When do subscribers actually process the event?
Subscribers process the event only after Event Grid routes and delivers it, as shown in step 5 of the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the Event Grid State at step 3?
AEvent received
BEvent matched
CRouting in progress
DWaiting for event
💡 Hint
Check the 'Event Grid State' column at step 3 in the execution_table.
At which step do subscribers start processing the event?
AStep 2
BStep 3
CStep 5
DStep 4
💡 Hint
Look at the 'Subscriber Action' column in the execution_table.
If no subscriptions match the event, what would the routing decision be at step 3?
ANo routing
BSend event to subscribers
CRoute to subscriber A and B
DEvent delivered
💡 Hint
Refer to the 'Routing Decision' column at step 3 in the execution_table.
Concept Snapshot
Event Grid routes events from sources to subscribers.
It receives events, matches subscriptions, then routes events.
Subscribers process events only after delivery.
If no subscription matches, event is not routed.
This enables decoupled, scalable event-driven apps.
Full Transcript
Event Grid is a service that routes events from sources to subscribers. When an event source emits an event, Event Grid receives it and checks which subscribers have registered for that event type. It then routes the event to those subscribers. Subscribers process the event only after receiving it from Event Grid. If no subscribers match, the event is not routed. This flow allows applications to react to events in a scalable and decoupled way.

Practice

(1/5)
1. What is the main purpose of Azure Event Grid in cloud applications?
easy
A. To route events from sources to event handlers automatically
B. To store large amounts of data for analytics
C. To create virtual machines for compute power
D. To manage user identities and access control

Solution

  1. Step 1: Understand Event Grid's role

    Event Grid is designed to route events from sources to handlers automatically, enabling reactive applications.
  2. Step 2: Compare with other services

    Other options describe different Azure services: storage, compute, and identity management, not event routing.
  3. Final Answer:

    To route events from sources to event handlers automatically -> Option A
  4. Quick Check:

    Event routing = To route events from sources to event handlers automatically [OK]
Hint: Event Grid moves events, not data or users [OK]
Common Mistakes:
  • Confusing Event Grid with storage services
  • Thinking Event Grid manages virtual machines
  • Mixing Event Grid with identity services
2. Which Azure CLI command correctly creates an Event Grid subscription named mySub for a topic myTopic?
easy
A. az eventgrid subscription create --topic myTopic --name mySub
B. az eventgrid event-subscription create --name mySub --source-resource-id myTopic
C. az eventgrid topic create --name mySub --source myTopic
D. az eventgrid event-subscription create --name mySub --source-resource-id /subscriptions/.../resourceGroups/.../providers/Microsoft.EventGrid/topics/myTopic

Solution

  1. Step 1: Identify correct CLI syntax for event subscription

    The command requires the full resource ID for the source topic using --source-resource-id.
  2. Step 2: Evaluate options

    az eventgrid event-subscription create --name mySub --source-resource-id /subscriptions/.../resourceGroups/.../providers/Microsoft.EventGrid/topics/myTopic uses the full resource ID format, which is required. az eventgrid event-subscription create --name mySub --source-resource-id myTopic lacks full resource ID, C creates a topic not subscription, D uses wrong command.
  3. Final Answer:

    az eventgrid event-subscription create --name mySub --source-resource-id /subscriptions/.../resourceGroups/.../providers/Microsoft.EventGrid/topics/myTopic -> Option D
  4. Quick Check:

    Full resource ID needed for subscription creation [OK]
Hint: Use full resource ID with --source-resource-id for subscriptions [OK]
Common Mistakes:
  • Using topic creation command instead of subscription
  • Omitting full resource ID in source
  • Using incorrect command names
3. Given this Azure CLI command output snippet for an Event Grid subscription:
{
  "destination": {
    "endpointType": "WebHook",
    "properties": {
      "endpointUrl": "https://myapp.com/api/events"
    }
  },
  "filter": {
    "subjectBeginsWith": "orders/",
    "subjectEndsWith": ".json"
  }
}
Which events will be delivered to the webhook endpoint?
medium
A. Only events with subjects exactly 'orders/.json'
B. All events regardless of subject
C. All events with subjects starting with 'orders/' and ending with '.json'
D. Events with subjects containing 'orders/' anywhere

Solution

  1. Step 1: Understand subject filters in Event Grid

    The filter uses subjectBeginsWith and subjectEndsWith to select events whose subject starts with 'orders/' and ends with '.json'.
  2. Step 2: Analyze options

    All events with subjects starting with 'orders/' and ending with '.json' matches the filter exactly. Only events with subjects exactly 'orders/.json' is too strict (exact match), C ignores filters, D is incorrect because 'contains' is not used.
  3. Final Answer:

    All events with subjects starting with 'orders/' and ending with '.json' -> Option C
  4. Quick Check:

    Subject filters = startsWith + endsWith [OK]
Hint: Filters combine start and end patterns, not exact or contains [OK]
Common Mistakes:
  • Assuming exact subject match required
  • Ignoring subject filters and expecting all events
  • Confusing contains with beginsWith or endsWith
4. You created an Event Grid subscription but your webhook endpoint is not receiving events. Which of these is the most likely cause?
medium
A. The Event Grid topic does not exist
B. The webhook endpoint URL is incorrect or unreachable
C. You forgot to create an Azure Storage account
D. The subscription filter matches all events

Solution

  1. Step 1: Check webhook endpoint accessibility

    If the webhook URL is wrong or the endpoint is down, events cannot be delivered.
  2. Step 2: Evaluate other options

    Topic existence is important but usually checked at creation; storage account is unrelated; a filter matching all events would not block delivery.
  3. Final Answer:

    The webhook endpoint URL is incorrect or unreachable -> Option B
  4. Quick Check:

    Endpoint must be reachable for event delivery [OK]
Hint: Check webhook URL and network access first [OK]
Common Mistakes:
  • Assuming storage account is needed for Event Grid
  • Ignoring endpoint network issues
  • Thinking filters block all events by default
5. You want to route events from multiple Azure Blob Storage accounts to a single Azure Function using Event Grid. What is the best approach to achieve this?
hard
A. Create an Event Grid subscription for each storage account, all pointing to the same Azure Function endpoint
B. Create one Event Grid subscription on one storage account and expect it to receive events from all accounts
C. Use Azure Logic Apps to poll each storage account and forward events to the function
D. Configure the Azure Function to listen directly to all storage accounts without Event Grid

Solution

  1. Step 1: Understand Event Grid subscription scope

    Event Grid subscriptions are scoped to a single resource, so each storage account needs its own subscription.
  2. Step 2: Evaluate options

    Create an Event Grid subscription for each storage account, all pointing to the same Azure Function endpoint correctly creates multiple subscriptions pointing to one function. Create one Event Grid subscription on one storage account and expect it to receive events from all accounts is invalid because one subscription cannot cover multiple accounts. Use Azure Logic Apps to poll each storage account and forward events to the function adds unnecessary polling. Configure the Azure Function to listen directly to all storage accounts without Event Grid is not supported as functions rely on Event Grid for event routing.
  3. Final Answer:

    Create an Event Grid subscription for each storage account, all pointing to the same Azure Function endpoint -> Option A
  4. Quick Check:

    One subscription per source resource [OK]
Hint: Each source needs its own subscription to route events [OK]
Common Mistakes:
  • Assuming one subscription covers multiple sources
  • Using polling instead of event-driven routing
  • Expecting Azure Function to listen without Event Grid