Part of the Azure Functions Python DX Toolkit — dogfood-tested by azure-functions-cookbook-python.
This package is part of the Azure Functions Python DX Toolkit.
| Package | Role |
|---|---|
| azure-functions-openapi-python | OpenAPI spec generation and Swagger UI |
| azure-functions-validation-python | Request/response validation and serialization |
| azure-functions-db-python | Database bindings for SQL, PostgreSQL, MySQL, SQLite, and Cosmos DB |
| azure-functions-langgraph-python | LangGraph deployment adapter for Azure Functions |
| azure-functions-scaffold-python | Project scaffolding CLI |
| azure-functions-logging-python | Structured logging and observability |
| azure-functions-doctor-python | Pre-deploy diagnostic CLI |
| azure-functions-durable-graph-python | Manifest-first graph runtime with Durable Functions (experimental) |
| azure-functions-knowledge-python | Knowledge retrieval (RAG) decorators |
| azure-functions-cookbook-python | Dogfood examples — runnable recipes that exercise the full toolkit |
Read this in: 한국어 | 日本語 | 简体中文
Knowledge retrieval (RAG) decorators for Azure Functions Python v2.
- Decorator-based API — Seamless integration with Azure Functions Python v2 programming model
- Provider abstraction — Pluggable knowledge providers via protocol-based interface
- Notion support — Built-in Notion provider for searching and retrieving pages
- Async support — Automatic async offloading for non-blocking execution
- Environment variable resolution —
%VAR%placeholder substitution for secure credential handling
pip install azure-functions-knowledge-python[notion]import azure.functions as func
from azure_functions_knowledge import Document, KnowledgeBindings
app = func.FunctionApp()
kb = KnowledgeBindings()
@app.route(route="search", methods=["GET"])
@kb.input(
"docs",
provider="notion",
query=lambda req: req.params.get("q", ""),
top=5,
connection="%NOTION_TOKEN%",
)
def search(req: func.HttpRequest, docs: list[Document]) -> func.HttpResponse:
import json
results = [{"title": d.title, "url": d.url} for d in docs]
return func.HttpResponse(json.dumps(results), mimetype="application/json")Searches a knowledge provider and injects results into the handler:
@kb.input("docs", provider="notion", query="roadmap", connection="%NOTION_TOKEN%")
def handler(timer, docs: list[Document]) -> None:
for doc in docs:
print(doc.title, doc.url)Dynamic queries from handler parameters:
@kb.input(
"docs",
provider="notion",
query=lambda req: req.params.get("q", ""),
connection="%NOTION_TOKEN%",
)
def handler(req, docs: list[Document]) -> func.HttpResponse:
...Injects a provider instance for imperative control:
@kb.inject_client("client", provider="notion", connection="%NOTION_TOKEN%")
def handler(req, client) -> func.HttpResponse:
doc = client.get_document(page_id)
results = client.search("query", top=10)
...- Azure decorators outermost, knowledge decorators closest to the function
inputandinject_clientare mutually exclusive- No decorator can be applied twice to the same handler
connection="%NOTION_TOKEN%" # Single env var
connection="Bearer %API_KEY%" # Partial substitution
connection={"token": "%MY_TOKEN%"} # Mapping with substitutionImplement the KnowledgeProvider protocol and register:
from azure_functions_knowledge import Document, register_provider
class MyProvider:
def __init__(self, *, connection, **kwargs):
...
def search(self, query: str, *, top: int = 5) -> list[Document]:
...
def get_document(self, document_id: str) -> Document:
...
def close(self) -> None:
...
register_provider("my-provider", MyProvider)Full documentation: https://yeongseon.github.io/azure-functions-knowledge-python/
git clone https://github.com/yeongseon/azure-functions-knowledge-python.git
cd azure-functions-knowledge-python
make install
make check-allMIT License. See LICENSE for details.