Azure Functions Python Cookbook¶
Practical, production-oriented patterns for building Azure Functions with the Python v2 programming model.
What this project is
This cookbook is the dogfood of the Azure Functions Python DX Toolkit. Every example is a real, runnable Azure Function that uses the toolkit libraries in production-realistic scenarios. It is not a runtime library you install as an application dependency — it is proof that the toolkit works end-to-end.
Why this cookbook exists¶
Azure Functions documentation is broad, but many teams still need concrete, copy-adapt-run patterns for common workloads. This cookbook closes that gap by pairing clear pattern narratives with runnable examples — each of which exercises the toolkit libraries the way a real application would.
What you get¶
- 75 patterns across 14 categories covering APIs, messaging, orchestration, AI, and more
- 75 runnable example projects under
examples/, organized by category - Dogfood coverage: 40 examples use
azure-functions-logging, 23 useazure-functions-openapiandazure-functions-validation, 9 useazure-functions-db - Production considerations in every pattern
- Mermaid architecture and behavior diagrams
Pattern catalog¶
APIs & Ingress¶
- Hello HTTP Minimal — minimal route handler
- HTTP Routing, Query, and Body — parse params and JSON body
- HTTP Auth Levels — function vs anonymous vs admin keys
- GitHub Webhook — secure signed event ingestion
- EasyAuth Claims — EasyAuth principal extraction
- JWT Validation — JWT Bearer token validation
- Multi-Tenant Auth — multi-tenant access control
- BFF Facade API — backend-for-frontend aggregation
- Full-Stack CRUD API — complete CRUD with toolkit
Async APIs & Jobs¶
- Async HTTP 202 Polling — accepted with polling
- Queue-Backed Job — deferred job processing
- Callback Completion — async callback pattern
Messaging & Pub/Sub¶
- Queue Producer — enqueue messages via output binding
- Queue Consumer — process messages with retry semantics
- Service Bus Worker — durable message processing
- Event Grid Event Router
- Service Bus Topic Fanout
- Service Bus Sessions
- Service Bus DLQ Replay
- Event Grid Domain Events
Streams & Telemetry¶
- Event Hub Consumer — high-throughput stream processing
- Event Hub Batch Window
- Event Hub Checkpoint Replay
Blob & File Triggers¶
- Blob Upload Processor — react to new blob arrivals
- Blob Event Grid Trigger — Event Grid-backed blob trigger
Scheduled & Background¶
- Timer Cron Job — scheduled maintenance and periodic automation
Orchestration & Workflows¶
- Hello Sequence — basic orchestration chain
- Fan-Out / Fan-In — parallel activity execution
- Human Interaction — approval and wait patterns
- Entity Counter — stateful entity pattern
- Retry Pattern — activity-level retry strategies
- Determinism Gotchas — pitfalls to avoid
- Unit Testing — test orchestrations without a host
- Saga Compensation — compensating transactions
- Sub-Orchestration — nested orchestrations
- Async Job Lifecycle — durable job management
Reliability¶
- Retry and Idempotency — safe retries and deduplication
- Circuit Breaker — fault isolation
- Outbox Pattern — reliable messaging
- Poison Message Handling — dead letter processing
- Rate Limiting Throttle — request throttling
Security & Tenancy¶
- Managed Identity (Storage) — keyless storage access
- Managed Identity (Service Bus) — keyless bus access
- Secretless Key Vault — keyless secrets access
- Tenant Isolation — multi-tenant data separation
Runtime & Ops¶
- Blueprint Modular App — split handlers across modules
- Output Binding vs SDK — when to use bindings vs direct calls
- host.json Tuning — concurrency and retry knobs
- Concurrency Tuning — worker process and thread settings
- Observability Tracing — distributed tracing
- Cold Start Mitigation — warm-up strategies
Data & Pipelines¶
- Change Feed Processor — Cosmos DB downstream sync
- DB Input and Output — database CRUD with azure-functions-db-python
- File Processing Pipeline
- CQRS Read Projection
- SQLAlchemy REST Pagination
- ETL Enrichment
AI & Agents¶
- MCP Server — Model Context Protocol server example
- LangGraph Agent — LangGraph RAG agent
- RAG Knowledge API — RAG search endpoint
- LangGraph RAG Agent — LangGraph agent deployment
- Azure OpenAI Direct Chat — chat completion endpoint
- Durable AI Pipeline — multi-step AI orchestration
- Streaming AI Response — SSE streaming from Azure OpenAI
- AI Image Generation — DALL-E 3 image generation
- Embedding Vector Search — embeddings + vector search
Guides¶
- Local Run and Direct Invoke — test without deploying
- Scaffold Quick Start — generate projects with afs
- Testing Patterns — unit, integration, and e2e testing
Quick start¶
git clone https://github.com/yeongseon/azure-functions-cookbook-python.git
cd azure-functions-cookbook-python
python -m venv .venv
source .venv/bin/activate
Run one example:
Then test:
Recommended learning path¶
- Installation
- Getting Started
- Patterns Overview
- Pick one deep-dive pattern page
- Run the matching
examples/<category>/<name>project - Validate with Testing
Repository map¶
docs/patterns/ Pattern deep-dives organized by category
docs/foundations/ Core concepts (execution model, triggers & bindings)
docs/reference/ Reference pages (durable functions, etc.)
docs/guides/ Practical guides (deployment, identity, IaC, scaffold)
examples/ Runnable Azure Functions app implementations
Ecosystem projects¶
These companion projects are optional accelerators — the cookbook works independently without them:
azure-functions-scaffold-python— project bootstrap from known templatesazure-functions-validation-python— request/response validation helpersazure-functions-openapi-python— generated API contracts and Swagger UIazure-functions-logging-python— structured telemetry and diagnosticsazure-functions-doctor-python— local environment diagnosisazure-functions-db-python— database integration helpersazure-functions-langgraph-python— LangGraph agent deployment
Contributing and quality¶
If you want to improve patterns or examples:
- Use Development for workflow
- Use Testing before submitting changes
- Follow Contributing Guidelines
Additional references¶
- Core concepts: Foundations
- Planned expansion: Roadmap
- Common failures and fixes: Troubleshooting
- Frequently asked questions: FAQ
Tip
The fastest path to value is: pick one pattern, run its example, then adapt for your production constraints.