Bird
Raised Fist0
Azurecloud~20 mins

Event Grid subscriptions and filters in Azure - Practice Problems & Coding Challenges

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
Challenge - 5 Problems
🎖️
Event Grid Filter Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate
2:00remaining
Event Grid subscription filter behavior

You create an Event Grid subscription with a filter that only allows events where data.category equals "sales". Which events will be delivered to the subscriber?

AAll events will be delivered regardless of <code>data.category</code> value.
BOnly events with <code>data.category</code> exactly equal to "sales" will be delivered.
CEvents with <code>data.category</code> containing the word "sales" anywhere will be delivered.
DNo events will be delivered because filters do not support <code>data</code> properties.
Attempts:
2 left
💡 Hint

Think about how exact matching works in Event Grid filters.

❓ Configuration
intermediate
2:00remaining
Event Grid advanced filter configuration

You want to create an Event Grid subscription that only receives events where data.amount is greater than 100 and data.region is either "US" or "EU". Which filter configuration achieves this?

AUse two advanced filters: one numeric filter for <code>data.amount &gt; 100</code> and one string filter with <code>In</code> operator for <code>data.region</code> in ["US", "EU"] combined with AND.
BUse a simple filter with <code>data.amount &gt; 100</code> and ignore <code>data.region</code>.
CUse a simple filter with <code>data.region</code> equals "US" or "EU" but no numeric filter.
DUse two filters combined with OR: one for <code>data.amount &gt; 100</code> and one for <code>data.region</code> in ["US", "EU"].
Attempts:
2 left
💡 Hint

Remember that multiple filters combined with AND require all conditions to be true.

❓ Architecture
advanced
2:00remaining
Designing Event Grid subscriptions for multi-tenant filtering

You have an Event Grid topic publishing events for multiple tenants. You want each tenant to receive only their own events based on data.tenantId. What is the best architecture to achieve this with minimal subscriptions?

ACreate one subscription per tenant with a filter on <code>data.tenantId</code> matching the tenant's ID.
BCreate a single subscription without filters and let tenants filter events on their side.
CCreate one subscription with a filter that matches all tenant IDs using a wildcard.
DCreate one subscription per event type ignoring tenant filtering.
Attempts:
2 left
💡 Hint

Consider how Event Grid filters can isolate events per tenant.

❓ security
advanced
2:00remaining
Securing Event Grid subscriptions with filters

You want to prevent unauthorized event delivery by ensuring only events with a specific subject prefix are delivered to your subscription. Which filter setup enforces this?

AUse a subject ends with filter with the required prefix.
BUse a filter on <code>data</code> properties ignoring the subject.
CUse no filters and rely on network security groups to block events.
DUse a subject begins with filter with the required prefix on the subscription.
Attempts:
2 left
💡 Hint

Think about how subject filters work in Event Grid.

✅ Best Practice
expert
3:00remaining
Optimizing Event Grid subscription filters for cost and performance

You manage an Event Grid topic with thousands of event types and many subscriptions. To reduce cost and improve performance, which filtering strategy is best?

AUse multiple complex advanced filters on data properties for each subscription.
BUse no filters and filter events in subscriber applications.
CUse subject prefix filters to limit events per subscription instead of complex data property filters.
DCreate one subscription for all events and distribute filtering downstream.
Attempts:
2 left
💡 Hint

Consider the cost and latency impact of filtering at the Event Grid service versus subscriber side.

Practice

(1/5)
1. What is the main purpose of using filters in Azure Event Grid subscriptions?
easy
A. To receive only specific events based on criteria like event type or subject
B. To increase the number of events sent to subscribers
C. To block all events from being delivered
D. To change the event data before delivery

Solution

  1. Step 1: Understand Event Grid subscriptions

    Subscriptions let you receive events from Azure services.
  2. Step 2: Role of filters in subscriptions

    Filters help select only the events you want, based on event type or subject.
  3. Final Answer:

    To receive only specific events based on criteria like event type or subject -> Option A
  4. Quick Check:

    Filters select events = B [OK]
Hint: Filters pick events you want, ignoring others [OK]
Common Mistakes:
  • Thinking filters increase event volume
  • Believing filters block all events
  • Assuming filters modify event data
2. Which of the following is the correct JSON snippet to filter events by subject prefix in an Event Grid subscription?
easy
A. "filter": { "subjectBeginsWith": "/blobServices/default/containers/images" }
B. "filter": { "subjectEndsWith": "/blobServices/default/containers/images" }
C. "filter": { "eventType": "Microsoft.Storage.BlobCreated" }
D. "filter": { "subjectContains": "images" }

Solution

  1. Step 1: Identify subject prefix filter syntax

    The correct property to filter by subject prefix is "subjectBeginsWith".
  2. Step 2: Match the correct JSON snippet

    "filter": { "subjectBeginsWith": "/blobServices/default/containers/images" } uses "subjectBeginsWith" with the correct path prefix.
  3. Final Answer:

    "filter": { "subjectBeginsWith": "/blobServices/default/containers/images" } -> Option A
  4. Quick Check:

    Prefix filter uses subjectBeginsWith = A [OK]
Hint: Prefix filters use subjectBeginsWith property [OK]
Common Mistakes:
  • Confusing subjectEndsWith with subjectBeginsWith
  • Using eventType instead of subject filter
  • Using subjectContains which is not valid
3. Given this Event Grid subscription filter configuration:
{ "subjectBeginsWith": "/devices/", "subjectEndsWith": "/temperature" }

Which event subject will be delivered to the subscriber?
medium
A. /sensors/device123/temperature
B. /devices/device123/humidity
C. /devices/device123/temperature
D. /devices/temperature/device123

Solution

  1. Step 1: Understand filter conditions

    The event subject must start with "/devices/" and end with "/temperature".
  2. Step 2: Check each option

    /devices/device123/temperature matches both start and end. Others fail one condition.
  3. Final Answer:

    /devices/device123/temperature -> Option C
  4. Quick Check:

    Subject starts with /devices/ and ends with /temperature = A [OK]
Hint: Match both start and end strings exactly [OK]
Common Mistakes:
  • Ignoring subjectEndsWith condition
  • Confusing similar paths
  • Assuming partial matches are enough
4. You wrote this filter in your Event Grid subscription:
{ "subjectBeginsWith": "/orders/", "subjectEndsWith": "/completed" }

But no events are received even though events exist. What is the likely issue?
medium
A. The subscription is disabled
B. The filter syntax is invalid JSON
C. Event Grid does not support subject filters
D. The subject filter is case-sensitive and event subjects differ in case

Solution

  1. Step 1: Check filter syntax and support

    The JSON syntax is valid and Event Grid supports subject filters.
  2. Step 2: Consider case sensitivity and subscription status

    Subject filters are case-sensitive; if event subjects differ in case, no match occurs. Subscription being disabled would stop all events, but question implies filter issue.
  3. Final Answer:

    The subject filter is case-sensitive and event subjects differ in case -> Option D
  4. Quick Check:

    Subject filters are case-sensitive = D [OK]
Hint: Remember filters are case-sensitive in Event Grid [OK]
Common Mistakes:
  • Assuming filters ignore case
  • Blaming JSON syntax without checking
  • Ignoring subscription status
5. You want to create an Event Grid subscription that only receives events of type Microsoft.Storage.BlobCreated where the blob is in the container named images. Which filter configuration achieves this?
hard
A. { "eventType": "Microsoft.Storage.BlobDeleted", "subjectBeginsWith": "/blobServices/default/containers/images/" }
B. { "eventType": "Microsoft.Storage.BlobCreated", "subjectBeginsWith": "/blobServices/default/containers/images/" }
C. { "eventType": "Microsoft.Storage.BlobCreated", "subjectEndsWith": "/images" }
D. { "eventType": "Microsoft.Storage.BlobCreated" }

Solution

  1. Step 1: Filter by event type

    The event type must be exactly "Microsoft.Storage.BlobCreated" to get blob creation events.
  2. Step 2: Filter by subject prefix for container

    The subject prefix for blobs in the "images" container is "/blobServices/default/containers/images/".
  3. Step 3: Combine filters correctly

    { "eventType": "Microsoft.Storage.BlobCreated", "subjectBeginsWith": "/blobServices/default/containers/images/" } combines both eventType and subjectBeginsWith correctly.
  4. Final Answer:

    { "eventType": "Microsoft.Storage.BlobCreated", "subjectBeginsWith": "/blobServices/default/containers/images/" } -> Option B
  5. Quick Check:

    Event type and subject prefix filter combined = C [OK]
Hint: Combine eventType and subjectBeginsWith for precise filtering [OK]
Common Mistakes:
  • Using wrong event type
  • Using subjectEndsWith instead of subjectBeginsWith
  • Omitting container path in subject filter