Azure Cloud Integration
Cloud integration involves connecting applications and services through APIs, messaging, and events. The AZ-204 exam focuses on API Management, Service Bus, Event Grid, and Event Hubs.API Management
Azure API Management (APIM) is a gateway that publishes, secures, transforms, and monitors APIs.Products and Subscriptions
Products bundle APIs for developer consumption with subscription-based access control. Product Types:- Open - No subscription required, anonymous access
- Protected - Requires subscription key approval
- Sent via
Ocp-Apim-Subscription-Keyheader orsubscription-keyquery parameter - Primary and secondary keys enable zero-downtime rotation
Policy Definitions
APIM policies are XML statements executing in the request/response pipeline. Pipeline Sections:- inbound - Process request before backend
- backend - Modify backend request
- outbound - Transform response
- on-error - Handle errors
validate-jwt- Token validationrate-limit-by-key- Throttlingcache-lookup/cache-store- Response cachingset-header- Header manipulationrewrite-uri- URL rewriting
Use
validate-jwt policy in APIM to offload token validation from your backend API - this reduces auth overhead and centralizes security policy.Rate Limiting and Quotas
Throttle API calls to protect backends from overload. Policy Types:- rate-limit - Per-subscription, per-period throttle
- rate-limit-by-key - Flexible key (IP, user, custom)
- quota-by-key - Call or bandwidth quota over longer period
Response Caching
Cache backend responses in the gateway to reduce latency and load. Cache Policies:cache-lookup- Check cache before calling backendcache-store- Store response in cachevary-by-header/vary-by-query-parameter- Partition cache
Messaging Services
Service Bus Queues
Enterprise messaging with reliable delivery and advanced features. Key Features:- FIFO with optional sessions for strict ordering
- Peek-lock - Lease message, delete on explicit Complete()
- Dead-letter queue (DLQ) - Unprocessable or expired messages
- Duplicate detection - Idempotent sends in configurable window
- Sessions - Ordered delivery by session ID
- Scheduled delivery - EnqueuedTimeUtc for future delivery
Service Bus Topics
Publish-subscribe messaging with filter-based subscriptions. Key Features:- Topic → multiple subscriptions, each gets a copy
- Filters: SQL filter (expression), correlation filter (exact match), True filter (all)
- Each subscription supports DLQ, sessions, peek-lock
- Max 2000 subscriptions per topic
Dead-Letter Queues
DLQs receive messages that cannot be delivered or processed. Auto-DLQ Triggers:- MaxDeliveryCount exceeded (default 10)
- TTL expired with
enableDeadLetteringOnMessageExpiration=true - Explicit
DeadLetterMessageAsync()with custom reason
Event Grid
HTTP-based reactive event routing at massive scale. Key Features:- Event Grid schema or CloudEvents 1.0
- Built-in retry with exponential backoff (24 hours)
- Dead-letter support for undeliverable events
- Filter by event type or subject
- At-least-once delivery - design handlers to be idempotent
Event Grid delivers at-least-once - design event handlers to be idempotent. Use event ID deduplication if your handler must process each event exactly once.
Event Hubs
High-throughput event streaming and ingestion platform. Key Features:- Partitions - 2-32 (basic), more in premium/dedicated
- Consumer groups - Independent read pointers per application
- Retention - 1-7 days (standard), up to 90 days (premium)
- Kafka-compatible - Reuse Kafka producers/consumers
- Capture - Auto-archive to Blob/ADLS in Avro format
- Throughput units (TU) - 1 TU = 1 MB/s in, 2 MB/s out
Service Comparison
- When to Use Queues
- When to Use Topics
- When to Use Event Grid
- When to Use Event Hubs
Azure Storage Queue:
- Simple FIFO queue
- Messages up to 64 KB
- Millions of messages
- At-least-once delivery
- Enterprise features
- Messages up to 256 KB (1 MB premium)
- Exactly-once delivery
- Sessions, DLQ, duplicate detection
Integration with Functions
Azure Functions integrates natively with messaging services.Use
autoCompleteMessages=false setting on Service Bus triggers when you need manual control over message completion/abandonment.Exam Checklist
- Understand APIM products and subscription keys
- Know policy pipeline sections and common policies
- Understand rate limiting and quota policies
- Know response caching patterns
- Understand Service Bus queues vs topics
- Know dead-letter queue triggers and monitoring
- Understand duplicate detection requirements
- Know Event Grid vs Event Hubs use cases
- Understand at-least-once delivery patterns
- Know Function triggers for messaging services