This release is a pre-release and may not be stable for production use.
Azure Functions Boot
A powerful framework for building Azure Functions applications with built-in dependency injection and controller-based architecture.
Created by: Santiago Vasquez Gomez
Features
- Dependency Injection Container: Full-featured DI container with three service lifetimes (Singleton, Transient, Scoped)
- Controller-based Architecture: Organize Azure Functions triggers (HTTP, Queue, Timer, Blob, etc.) using controller classes
- Automatic Discovery: Automatically discovers and registers controllers and service registries
- Scope Management: Automatic scope creation and disposal for scoped services
- Async/Sync Support: Seamless support for both async and synchronous methods
- Type-Based Resolution: Automatic dependency resolution using Python type annotations
- IDisposable Pattern: Built-in support for resource cleanup
- Flexible Architecture: The framework is flexible and doesn't enforce a specific structure. You can organize your code however you prefer.
Installation
pip install azfunc-boot
Quick Start
1. Create a Service Registry
from azfunc_boot import BaseServiceRegistry, DependencyContainer, register_service
class ServicesRegistry(BaseServiceRegistry):
def __init__(self, container: DependencyContainer):
self.container = container
super().__init__()
@register_service
def register_services(self):
# Simple registration
self.container.add_scoped(ExampleService)
# Registration with interface using lambda
self.container.add_scoped(
IExampleService,
lambda: ExampleService(self.container.get_service(ExampleDisposableClient)),
)
2. Create a Controller
import logging
from azfunc_boot import BaseController, DependencyContainer
import azure.functions as func
from services.example_service import ExampleService
class ExampleController(BaseController):
PATH = "example"
def __init__(self, container: DependencyContainer, bp: func.Blueprint):
super().__init__(container, bp)
self._logger = logging.getLogger(__name__)
def register_routes(self):
self.bp.route(self.PATH, methods=["GET"])(self.example_method)
async def example_method(self, req: func.HttpRequest) -> func.HttpResponse:
self._logger.info("Example method called")
param = req.params.get("param")
if not param:
return func.HttpResponse("Param is required", status_code=400)
service: ExampleService = self.container.get_service(ExampleService)
try:
result = await service.example_method(param)
return func.HttpResponse(result, status_code=200)
except Exception as e:
self._logger.error(f"Error in example_method: {e}")
return func.HttpResponse(f"Error: {e}", status_code=500)
3. Bootstrap Your Application
import logging
import azure.functions as func
from azfunc_boot import create_app
logging.basicConfig(level=logging.INFO, force=True)
# Create the application using the framework
app, container = create_app(
controllers_package="controllers", registries_package="registries"
)
@app.route("health_check", methods=["GET"], auth_level=func.AuthLevel.ANONYMOUS)
def health_check(req: func.HttpRequest) -> func.HttpResponse:
"""Health check endpoint"""
return func.HttpResponse("Healthy", status_code=200)
Service Registration
The framework supports two ways to register services in your registry:
Simple Registration
When the service class can be instantiated automatically by the container (all dependencies are registered services with type annotations):
@register_service
def register_services(self):
self.container.add_scoped(ExampleService)
self.container.add_singleton(Configuration)
self.container.add_transient(SomeService)
Lambda Registration
Use a lambda function when:
- The service implements an interface/abstraction
- The constructor requires primitive types (strings, numbers, etc.)
- You need custom instantiation logic
With interface:
@register_service
def register_services(self):
self.container.add_scoped(
IExampleService,
lambda: ExampleService(self.container.get_service(ExampleDisposableClient)),
)
With primitive types:
@register_service
def register_services(self):
self.container.add_scoped(
ExampleService,
lambda: ExampleService(
connection_string="your-connection-string",
timeout=30,
client=self.container.get_service(ExampleDisposableClient)
),
)
Service Lifetimes
The framework supports three service lifetimes:
- Singleton: A single instance is created and reused throughout the application lifetime
- Scoped: A new instance is created per scope (typically per HTTP request or function invocation)
- Transient: A new instance is created every time the service is requested
All three lifetimes support both simple and lambda registration (see Service Registration above).
# Singleton
container.add_singleton(ServiceClass)
container.add_singleton(IService, lambda: ServiceClass(...))
# Scoped
container.add_scoped(ServiceClass)
container.add_scoped(IService, lambda: ServiceClass(...))
# Transient
container.add_transient(ServiceClass)
container.add_transient(IService, lambda: ServiceClass(...))
Dependency Injection
Constructor Injection
The framework automatically resolves dependencies using type annotations:
class UserService:
def __init__(self, repository: IUserRepository, logger: ILogger):
self.repository = repository
self.logger = logger
Manual Resolution
# Get a service
service = container.get_service(IService)
# Get all implementations (if multiple registered)
services = container.get_service(IService) # Returns list if multiple
List Injection
Inject multiple implementations of the same interface:
class Processor:
def __init__(self, strategies: list[IStrategy]):
self.strategies = strategies # List of all registered IStrategy implementations
Controllers
Base Controller
All controllers must inherit from BaseController:
import logging
from azfunc_boot import BaseController, DependencyContainer
import azure.functions as func
class MyController(BaseController):
PATH = "my-endpoint"
def __init__(self, container: DependencyContainer, bp: func.Blueprint):
super().__init__(container, bp)
self._logger = logging.getLogger(__name__)
def register_routes(self):
self.bp.route(self.PATH, methods=["GET"])(self.my_method)
async def my_method(self, req: func.HttpRequest) -> func.HttpResponse:
# Your route handler logic here
return func.HttpResponse("OK", status_code=200)
Automatic Scope Management
Controllers automatically create and dispose scoped services:
async def create_user(self, req: func.HttpRequest) -> func.HttpResponse:
# A scope is automatically created for this request
# Scoped services are automatically disposed after the request
user_service = self.container.get_service(IUserService)
# ... your code
Supported Triggers
The framework supports all Azure Functions triggers:
- HTTP triggers (
self.bp.route) - Timer triggers (
self.bp.timer_trigger) - Blob triggers (
self.bp.blob_trigger) - Service Bus triggers (
self.bp.service_bus_queue_trigger) - Event Hub triggers (
self.bp.event_hub_trigger) - Cosmos DB triggers (
self.bp.cosmos_db_trigger) - And more...
Resource Cleanup
Implement IDisposable for services that need cleanup:
from azfunc_boot import IDisposable
class DatabaseConnection(IDisposable):
async def dispose(self):
# Cleanup resources
await self.connection.close()
Scoped services implementing IDisposable are automatically disposed when the scope ends.
Error Handling
The framework provides custom exceptions:
NotFoundError: Raised when a service is not registeredValidationError: Raised for validation failures
Architecture
This framework is designed to be flexible and support various architectural patterns:
- Controllers (Adapters): Handle HTTP requests and Azure Functions triggers
- Services (Application Layer): Business logic and orchestration (optional)
- Repositories (Ports/Adapters): Data access abstraction (optional)
- Domain Models (Core): Business entities (optional)
Note: The framework doesn't enforce any specific structure. You can organize your code however you prefer - with or without service layers, client abstractions, or any other patterns. The only requirement is that controllers extend BaseController and registries extend BaseServiceRegistry.
Examples
See the example/ directory for complete working examples.
License
MIT License
Copyright (c) 2026 Santiago Vasquez Gomez (https://github.com/santiagovasquez1)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Metadata
Release files for azfunc-boot 1.0.0b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| azfunc_boot-1.0.0b1.tar.gz | 16.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| azfunc_boot-1.0.0b1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.9 kB
Release files / azfunc_boot-1.0.0b1.tar.gz
| Download URL | azfunc_boot-1.0.0b1.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aae46abd2fac76ba918653cb2d63e39c4a7cc3c7636168517cc50386b43b3ebe
|
|
BLAKE2b-256 checksum How to use checksums |
7f7c76e85f207ee8551af9160077f0f35774cd2cfdd2ef96e57423d31957f987
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.1 CPython/3.11.14 Linux/6.11.0-1018-azure
|
Release files / azfunc_boot-1.0.0b1-py3-none-any.whl
| Download URL | azfunc_boot-1.0.0b1-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e0eeffd4b13220ac884b6f5088f646936d445e7157f13d0289b3463031a92c1
|
|
BLAKE2b-256 checksum How to use checksums |
f20d6ac499b2f3ffa25c26b5ce4ff67b00836cea9c23a25327988d19cd4a51f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.1 CPython/3.11.14 Linux/6.11.0-1018-azure
|
Security for azfunc-boot 1.0.0b1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.