Validation and serialization layer for Azure Functions Python v2 programming model
Project description
Azure Functions Validation
Read this in: 한국어 | 日本語 | 简体中文
Validation and serialization for the Azure Functions Python v2 programming model.
Part of the Azure Functions Python DX Toolkit → Bring FastAPI-like developer experience to Azure Functions
Why this exists
Azure Functions Python v2 handlers often drift into the same repeated problems:
- Repeated manual parsing — every handler calls
req.get_json(),req.params.get(), handlesValueErrorindividually - Inconsistent error responses — some handlers return 400, others 422, formats vary across the project
- Missing response contracts — response payloads silently diverge from the intended schema
- No type safety — request data flows through as untyped dicts, bugs surface only at runtime
What it does
- Typed validation — body, query, path, and header parameters validated via Pydantic v2
- Automatic error responses — invalid requests get consistent
400/422JSON error bodies - Response model enforcement — mismatches raise
ResponseValidationError(HTTP 500) - Decorator-first API —
@validate_httpwraps your handler, no boilerplate needed
FastAPI comparison
| Feature | FastAPI | azure-functions-validation |
|---|---|---|
| Request body parsing | Built-in via type hints | @validate_http(body=Model) |
| Query/path/header validation | Query(), Path(), Header() |
@validate_http(query=Model, path=Model, headers=Model) |
| Response model | response_model= |
@validate_http(response_model=Model) |
| Validation errors | Automatic 422 | Automatic 422 with {"detail": [...]} |
| Error customization | Exception handlers | ErrorFormatter callback |
Scope
- Azure Functions Python v2 programming model
- HTTP-triggered functions registered on
func.FunctionApp() - Pydantic v2-based request and response validation
This package does not target the legacy function.json-based v1 programming model.
Features
- Typed body, query, path, and header validation via
@validate_http - Automatic 400 / 422 responses with
{"detail": [...]}envelope - Response model validation — mismatches raise
ResponseValidationError(HTTP 500) - Custom per-handler error formatting via
ErrorFormatter
Installation
pip install azure-functions-validation
Your Azure Functions app should also include:
azure-functions
azure-functions-validation
For local development:
git clone https://github.com/yeongseon/azure-functions-validation.git
cd azure-functions-validation
pip install -e .[dev]
Quick Start
import azure.functions as func
from pydantic import BaseModel
from azure_functions_validation import validate_http
class CreateUserRequest(BaseModel):
name: str
email: str
class CreateUserResponse(BaseModel):
message: str
status: str = "success"
app = func.FunctionApp()
@app.function_name(name="create_user")
@app.route(route="users", methods=["POST"], auth_level=func.AuthLevel.ANONYMOUS)
@validate_http(body=CreateUserRequest, response_model=CreateUserResponse)
def create_user(req: func.HttpRequest, body: CreateUserRequest) -> CreateUserResponse:
return CreateUserResponse(message=f"Hello {body.name}")
When to use
- You have HTTP-triggered Azure Functions that accept JSON request bodies
- You want Pydantic-based validation without writing manual parsing code
- You need consistent error response formats across handlers
- You want response schema enforcement to catch contract drift
Documentation
- Project docs live under
docs/ - Smoke-tested examples live under
examples/ - Product requirements:
PRD.md - Design principles:
DESIGN.md
Ecosystem
Part of the Azure Functions Python DX Toolkit:
| Package | Role |
|---|---|
| azure-functions-validation | Request and response validation |
| azure-functions-openapi | OpenAPI spec and Swagger UI |
| azure-functions-logging | Structured logging and observability |
| azure-functions-doctor | Pre-deploy diagnostic CLI |
| azure-functions-scaffold | Project scaffolding |
| azure-functions-python-cookbook | Recipes and examples |
Disclaimer
This project is an independent community project and is not affiliated with, endorsed by, or maintained by Microsoft.
Azure and Azure Functions are trademarks of Microsoft Corporation.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file azure_functions_validation-0.6.0.tar.gz.
File metadata
- Download URL: azure_functions_validation-0.6.0.tar.gz
- Upload date:
- Size: 86.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bc33dd2b230f5ea8bc27a2fa87b58e58359088270d44639278f1e8923286b5c
|
|
| MD5 |
0233bfd9b6be3f5a7ad96bc9923a5bbd
|
|
| BLAKE2b-256 |
fc627c9300236c22437bc3356a6f55f2e733bf438f53c7c5cf38f3b3cc4054f7
|
Provenance
The following attestation bundles were made for azure_functions_validation-0.6.0.tar.gz:
Publisher:
publish-pypi.yml on yeongseon/azure-functions-validation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
azure_functions_validation-0.6.0.tar.gz -
Subject digest:
9bc33dd2b230f5ea8bc27a2fa87b58e58359088270d44639278f1e8923286b5c - Sigstore transparency entry: 1193194494
- Sigstore integration time:
-
Permalink:
yeongseon/azure-functions-validation@38e30c6d663f5a1b0f0fdc3d57d4f7a852e99fb5 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/yeongseon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@38e30c6d663f5a1b0f0fdc3d57d4f7a852e99fb5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file azure_functions_validation-0.6.0-py3-none-any.whl.
File metadata
- Download URL: azure_functions_validation-0.6.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ecb4fb31419b9ee7043a113bcb0667cddc5faee7a96eaa40f111d468eafb988
|
|
| MD5 |
67c3252c5a5ac0ca4d4a1104eaf274f3
|
|
| BLAKE2b-256 |
3fa36cc2f9291a9a654ca1f028bfff7fcf6fd46efbc83a3838525cc475c0d73a
|
Provenance
The following attestation bundles were made for azure_functions_validation-0.6.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on yeongseon/azure-functions-validation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
azure_functions_validation-0.6.0-py3-none-any.whl -
Subject digest:
9ecb4fb31419b9ee7043a113bcb0667cddc5faee7a96eaa40f111d468eafb988 - Sigstore transparency entry: 1193194711
- Sigstore integration time:
-
Permalink:
yeongseon/azure-functions-validation@38e30c6d663f5a1b0f0fdc3d57d4f7a852e99fb5 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/yeongseon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@38e30c6d663f5a1b0f0fdc3d57d4f7a852e99fb5 -
Trigger Event:
push
-
Statement type: