Connect to and consume Azure services and third-party services →mediumMultiple ChoiceObjective-mapped
AZ-204 Practice Question: Connect to and consume Azure services and third-party services
You are using Azure Event Grid to respond to blob storage events (blob created). You need to ensure that only JPEG image files trigger a function for processing, while other files are ignored. The number of files is high, and you want to minimize cost and latency. How should you filter events?
⚠ Common exam trap
Test-takers frequently default to filtering inside the function code (Option A) because it seems simpler, but they overlook that Event Grid's advanced filtering can prevent the function from being triggered at all, which is the key to minimizing cost and latency in high-volume scenarios.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Configure Advanced Filters on the Event Grid subscription with a 'subjectEndsWith' condition set to '.jpg' or '.jpeg'.
Azure Event Grid supports advanced filtering on event properties, including 'subjectEndsWith', which allows you to filter events at the service level before they are delivered to the endpoint. This ensures that only blob creation events for files ending with '.jpg' or '.jpeg' trigger the function, reducing unnecessary invocations, cost, and latency. By filtering at the Event Grid level, you avoid processing unwanted events entirely, which is more efficient than filtering within the function code.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Create the function to check the blob extension at the start of the function code and return early if it's not a JPEG.
Why it's wrong here
This approach is inefficient because the Azure Function will still be triggered and executed for every single blob creation event, regardless of its file extension. While the function code can quickly exit, it still incurs execution costs for the invocation, cold start time, and resource consumption, even for non-JPEG files. Filtering at the application layer rather than the event routing layer leads to unnecessary resource utilization and increased operational costs.
- ✓
Configure Advanced Filters on the Event Grid subscription with a 'subjectEndsWith' condition set to '.jpg' or '.jpeg'.
Why this is correct
Configuring Advanced Filters on the Event Grid subscription is the most efficient and cost-effective solution. By setting a 'subjectEndsWith' condition to '.jpg' or '.jpeg', Event Grid will inspect the event's subject property, which typically contains the blob's full path and name, and only deliver events for matching file extensions. This pre-filters events at the platform level, preventing unnecessary function invocations and significantly reducing compute costs and latency.
- ✗
Create separate event subscriptions for each file extension and point them to different functions.
Why it's wrong here
Creating separate subscriptions per extension multiplies the number of Event Grid topics and function endpoints, increasing both cost and latency due to the overhead of managing many subscriptions, whereas a single subscription with an advanced filter on the `data.contentType` property can reject non-JPEG files before the event is delivered. This approach is tempting because separate subscriptions are a valid pattern for routing different event types to distinct logic, and would be correct if each extension required a completely different processing pipeline rather than a single filter.
- ✗
Use Event Hubs capture to filter files before sending events.
Why it's wrong here
Event Hubs is primarily designed for high-throughput stream ingestion and real-time data processing, not for content-based filtering of events before delivery. The Event Hubs Capture feature archives raw event streams to Azure Storage or Data Lake Storage, but it does not provide a mechanism to filter events based on their content or properties before they are sent to consumers. Therefore, it cannot be used to selectively filter blob creation events for specific file extensions.
Go deeper
Related to this question
About these practice questions
One of 881 original AZ-204 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-204 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-204 exam.