Add an Event Hubs Capture, Event Grid and Functions sample - #110
Open
DrisDary wants to merge 2 commits into
Open
Add an Event Hubs Capture, Event Grid and Functions sample#110DrisDary wants to merge 2 commits into
DrisDary wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The existing Event Hubs sample covers the hot path: events arrive, a consumer scores them, alerts go out. Nothing covers the cold path, which is how most production Event Hubs estates actually handle bulk analytics — Capture archives the stream to Blob Storage in Avro, Event Hubs announces each archive with
Microsoft.EventHub.CaptureFileCreated, and a Function App picks the archive up and aggregates it.That shape is worth a sample of its own because the reasoning is not obvious: the archive is already batched, ordered and durable, so aggregation reads whole windows instead of guessing batch boundaries, and it can be replayed from Blob Storage at any time. It is also the first sample to exercise Event Grid system topics, an Event Grid subscription with an Event Hubs destination, and a Function App driven by an Event Hubs trigger.
Changes
New sample at
samples/eventhubs-eventgrid/python, with the three deployment paths the other samples offer (scripts, Bicep, Terraform), all producing identical resource names.src/functions/function_app.py— theCaptureProcessor: an Event Hubs trigger withCardinality.MANY, which downloads each archive, decodes the Avro withfastavro, aggregates per device (count, min/mean/max temperature, excursions against a configurable limit) and writes summaries to a curated hub through an Event Hubs output binding.src/producers/telemetry_producer.py— publishes device telemetry, with a flag to make one device breach the temperature limit so the excursion path is actually exercised rather than assumed.scripts/—deploy.sh(nine steps),validate.sh(23 checks),run-pipeline.sh(the five-stage end-to-end demo),cleanup.sh, plusread_curated.pyandroundtrip_check.py.run-samples.sh— three CI entries, one per deployment path.README.md— one row for the new sample.A few decisions worth calling out for review:
EntityPath, which would pin the output binding to the notifications hub instead of the curated one.BlobEndpoint/QueueEndpoint/TableEndpointrather than usingEndpointSuffix, because the Functions host cannot parse a suffix that carries a port.skip_empty_archivesis on, so Capture does not raise a notification for a window that saw no readings.Tests
Verified end to end against an emulator built from the companion
localstack-probranch, running each deployment path on a fresh emulator (deleting a resource group is not sufficient — it orphans the Event Hubs namespace):All three produced the same six device summaries, with the seeded excursion device correctly flagged (
DEV-0003 … excursions 8), confirming the assertions are load-bearing rather than decorative.validate.shandrun-pipeline.shassert rather than narrate: every stage fails the script if the thing it claims did not happen, including that Capture actually wrote an archive, that the notification was delivered, and that summaries were produced. The CI entries rundeploy+validatefor every path and additionallyrun-pipelinefor the scripts path, so a sample that stops working turns the build red instead of passing quietly.Related
Requires the emulator changes in the companion
localstack-proPR —CaptureFileCreatedsystem events, Event Grid delivery to an Event Hubs destination, and the Python Function App dependency fix. This sample cannot pass CI until those ship in the image CI pulls, so this PR should merge after that one is released.SMF-790