Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Implement event-driven workflows by using Azure Event Grid, including filters, custom events, and retries

A worked example

Complete the statement

An AI platform publishes CloudEvents to an Event Grid custom topic. The exhibit shows a typical event.

You must create an event subscription for a review service. The subscription must deliver an event only when all of the following are true:

  • The event type is com.contoso.ai.InferenceCompleted or com.contoso.ai.AnomalyDetected.
  • The subject starts with /pipelines/embeddings.
  • The confidence score is greater than 0.9. An event whose score is exactly 0.9 must not be delivered.

{ "specversion": "1.0", "type": "com.contoso.ai.InferenceCompleted", "source": "/services/embeddings", "id": "evt-20261116-0001", "subject": "/pipelines/embeddings/batch-42", "datacontenttype": "application/json", "data": { "modelName": "embedder-v2", "status": "completed", "confidence": 0.95 } }

Complete the Azure CLI command.

az eventgrid event-subscription create \
  --name review-sub \
  --source-resource-id $topicid \
  --endpoint https://review.contoso.com/api/events \
  --included-event-types com.contoso.ai.InferenceCompleted com.contoso.ai.AnomalyDetected \
   /pipelines/embeddings \
  --advanced-filter   0.9
  • Blank 1: --subject-begins-with (correct answer)

    --subject-begins-with applies the required subject prefix match. --subject-ends-with matches a suffix instead. --included-event-types filters event types rather than subject paths.

  • Blank 2: data.confidence (correct answer)

    The score is in the event payload, and payload fields are addressed with the data. prefix, as in data.confidence. confidence without the prefix doesn't refer to the payload field. data.status holds a text status, not the score. subject is a path, not a number.

  • Blank 3: NumberGreaterThan (correct answer)

    NumberGreaterThan delivers only scores above 0.9. NumberGreaterThanOrEquals would also deliver a score of exactly 0.9, which is excluded. NumberLessThan selects the low-confidence events instead. StringContains is a text comparison, not a numeric threshold.

Why

Event type, subject prefix and advanced filters can all be set on one subscription, and an event must satisfy every one of them to be delivered. The subject requirement is a prefix match, so it uses the begins-with filter. The confidence threshold is a numeric comparison on a payload field, so it uses data.confidence with a strict greater-than operator, which leaves out events scored exactly 0.9.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free