Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Micro framework for azure functions with optional json schema validation

Project description


Build Status Latest Version Python Support

Python routing mini-framework for MS Azure Functions with optional JSON-schema validation.

** This repository is based heavily on lambdarest project


  • functionapp_handler function constructor with built-in dispatcher
  • Decorator to register functions to handle HTTP methods
  • Optional JSON-schema input validation using same decorator


Install the package from PyPI using pip:

pip install functionapprest

Getting Started

This module helps you to handle different HTTP methods in your Azure Functions.

from functionapprest import functionapp_handler

def my_own_get(event):
    return {'this': 'will be json dumped'}

Advanced Usage

Optionally you can validate an incoming JSON body against a JSON schema:

my_schema = {
    '$schema': '',
    'type': 'object',
    'properties': {
            'type': 'object',
            'properties': {
                'foo': {
                    'type': 'string'

@functionapp_handler.handle('get', path='/with-schema/', schema=my_schema)
def my_own_get(event):
    return {'this': 'will be json dumped'}

Query Params

Query params are also analyzed and validate with JSON schemas. Query arrays are expected to be comma separated, all numbers are converted to floats.

my_schema = {
    '$schema': '',
    'type': 'object',
    'properties': {
            'type': 'object',
            'properties': {
                'foo': {
                    'type': 'array',
                    'items': {
                        'type': 'number'

@functionapp_handler.handle('get', path='/with-params/', schema=my_schema)
def my_own_get(event):
    return event.json['query']


You can also specify which path to react on for individual handlers using the path param:

@functionapp_handler.handle('get', path='/foo/bar/baz')
def my_own_get(event):
    return {'this': 'will be json dumped'}

And you can specify path parameters as well, which will be passed as keyword arguments:

@functionapp_handler.handle('get', path='/foo/<int:id>/')
def my_own_get(event, id):
    return {'my-id': id}

Or use the proxy endpoint:

@functionapp_handler.handle('get', path='/bar/<path:path>')
def my_own_get(event, path):
    return {'path': path}

Using within Function App


  "scriptFile": "",
  "bindings": [
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
      "route": "products/{product_id}"
      "type": "http",
      "direction": "out",
      "name": "$return"

from functionapprest import functionapp_handler, Request

@functionapp_handler.handle('get', path='/products/<path:product_id>/')
def list_products(req: Request, product_id):
    query = req.json.get('query', {})
    body = req.json.get('body', {})
    headers = req.get('headers', {})
    params = req.get('params', {})
    response = {
        'method': req.method,
        'url': req.url,
        'headers': headers,
        'params': params,
        'query': query,
        'body': body
    return response

main = functionapp_handler


You can use pytest to run tests against your current Python version. To run tests for current python version run pytest

See for test dependencies and install them with pipenv install --dev.



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for functionapprest, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size functionapprest-0.2.0.tar.gz (9.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page