Overview
The Azure Functions Event Grid module enables Azure Functions to receive and dispatch Event Grid events to event handlers. This provides a serverless, event-driven architecture for reacting to changes across Azure services and custom applications. Azure Event Grid is a fully managed event routing service that enables event-driven, reactive programming using a publish-subscribe model.Installation
Dependencies
Intent.AzureFunctions- Core Azure Functions supportIntent.Eventing.AzureEventGrid- Event Grid eventing contractsIntent.Eventing.Contracts- Base eventing infrastructure
Event Grid Basics
Key Concepts
Topics - Endpoints where events are publishedEvent Subscriptions - Routes that filter and deliver events
Event Handlers - Applications that respond to events
Events - JSON messages describing what happened
Event Grid vs Service Bus
| Feature | Event Grid | Service Bus |
|---|---|---|
| Pattern | Event distribution | Message queuing |
| Latency | Sub-second | Seconds |
| Ordering | Not guaranteed | Guaranteed (sessions) |
| Use Case | Event notifications | Transaction processing |
Modeling Event Grid Consumers
In the Services Designer
- Create Integration Events in the Eventing designer
- Add Event Grid stereotype to mark events for Event Grid
- Model Event Handlers that subscribe to Event Grid events
Generated Consumer
Intent Architect generates Azure Functions that consume Event Grid events:Event Grid Event Structure
Event Grid events follow this schema:Event Sources
Azure Services
Event Grid supports many Azure service event sources:Blob Storage
Blob created, deleted, archived
Resource Manager
Resource created, updated, deleted
IoT Hub
Device created, deleted, telemetry
Container Registry
Image pushed, deleted
Custom Topics
Publish custom events to Event Grid:Processing Patterns
Single Event Processing
Batch Event Processing
Event Filtering
Filter events at the subscription level (configured in Azure):Event Validation
Subscription Validation
Event Grid validates webhook endpoints:Error Handling & Retry
Automatic Retry
Event Grid automatically retries failed deliveries:- Retry Schedule: Exponential backoff
- Maximum Attempts: 30 attempts over 24 hours
- Dead Letter: Configure dead-letter destination
Dead Letter Configuration
Exception Handling
Security
Managed Identity
Use managed identities for Event Grid authentication:Access Keys
Alternatively, use access keys (less recommended):Monitoring
Application Insights
Metrics to Monitor
- Delivery success rate
- Delivery latency
- Dead-letter count
- Failed delivery attempts
- Event age
Common Scenarios
Blob Storage Processing
Resource Change Notifications
Best Practices
Event Ordering
Event Ordering
Event Grid doesn’t guarantee order. Design handlers to be order-independent or use Event Hubs for ordered events.
Idempotency
Idempotency
Event Grid guarantees at-least-once delivery. Always implement idempotent handlers:
Event Versioning
Event Versioning
Plan for schema evolution:
- Use semantic versioning in
dataVersion - Make new fields optional
- Handle multiple versions in handlers
Cost Optimization
Cost Optimization
- Use advanced filters to reduce unnecessary events
- Batch operations when possible
- Consider consumption plan for variable loads
Local Development
Event Grid Emulator
Use the Event Grid simulator for local testing:ngrok for Webhook Testing
Expose local Functions to Event Grid:Resources
Event Grid Triggers
Official trigger documentation
Event Grid Schema
Event schema reference
Event Grid Eventing
Event Grid eventing module
Event Filtering
Advanced filtering guide
