Recipes
Practical recipes for building real-world Azure Functions with Python v2.
Each recipe is paired with a runnable project in examples/.
Tip
Read the recipe, then run the matching example.
Every example includes a function_app.py ready for func start.
HTTP
Timer
| Recipe |
Difficulty |
Description |
| Timer Cron Job |
Beginner |
NCRONTAB scheduled execution with past_due detection |
Queue
| Recipe |
Difficulty |
Description |
| Queue Producer |
Beginner |
HTTP POST to queue output binding with payload validation |
| Queue Consumer |
Beginner |
Queue trigger with JSON deserialization and dequeue-count logging |
Blob
Service Bus
| Recipe |
Difficulty |
Description |
| Service Bus Worker |
Intermediate |
Queue trigger with correlation ID tracking and dead-letter guidance |
Event Hub
| Recipe |
Difficulty |
Description |
| Event Hub Consumer |
Intermediate |
Partition-aware event processing with offset tracking |
Cosmos DB
| Recipe |
Difficulty |
Description |
| Change Feed Processor |
Intermediate |
Change feed trigger with lease container and batch processing |
Patterns
Durable Functions
| Recipe |
Difficulty |
Description |
| Hello Sequence |
Beginner |
Orchestrator chaining three sequential activities |
| Fan-Out / Fan-In |
Intermediate |
Parallel activity execution with context.task_all() |
| Human Interaction |
Intermediate |
Approval workflow with external event and timeout |
| Entity Counter |
Intermediate |
Durable entity with add/reset/get operations |
| Retry Pattern |
Intermediate |
call_activity_with_retry with RetryOptions |
| Determinism Gotchas |
Advanced |
Safe vs unsafe patterns in orchestrator replay |
| Unit Testing |
Advanced |
Mock-based testing with generator stepping |
AI
| Recipe |
Difficulty |
Description |
| MCP Server |
Advanced |
Model Context Protocol JSON-RPC 2.0 server over HTTP |
Local Development
How to Choose
Pick by your primary trigger:
- Synchronous request/response → HTTP recipes
- Scheduled execution → Timer recipe
- Async message processing → Queue or Service Bus recipes
- Event streaming → Event Hub recipe
- File processing → Blob recipes
- Change data capture → Cosmos DB recipe
- Multi-step workflows → Durable Functions recipes
- AI tool serving → MCP Server recipe
Then refine with patterns:
- Need modular code → Blueprint Modular App
- Need managed identity → Identity recipes
- Need performance tuning → host.json or Concurrency recipes
- Need reliability → Retry & Idempotency
Structure of Each Recipe
Every recipe follows a consistent format:
- Overview — What and why
- When to Use — Decision criteria
- Architecture — ASCII data-flow diagram
- Prerequisites — Tools and packages
- Project Structure — File layout
- Implementation — Code walkthrough with real snippets
- Run Locally — Step-by-step local execution
- Expected Output — What you should see
- Production Considerations — Scaling, retries, security
- Related Recipes — Cross-links