Expand description
§Armature Azure Functions
Azure Functions runtime adapter for Armature applications.
This crate allows you to deploy Armature applications to Azure Functions with HTTP triggers.
§Quick Start
ⓘ
use armature::prelude::*;
use armature_azure_functions::{AzureFunctionsRuntime, init_tracing};
#[controller("/")]
struct HelloController;
#[controller_impl]
impl HelloController {
#[get("/")]
async fn hello() -> &'static str {
"Hello from Azure Functions!"
}
}
#[module(controllers: [HelloController])]
struct AppModule;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize tracing for Application Insights
init_tracing();
// Create Armature application
let app = Application::create::<AppModule>();
// Run on Azure Functions
AzureFunctionsRuntime::new(app).run().await
}§With Azure Services
ⓘ
use armature_azure_functions::{AzureFunctionsRuntime, init_tracing};
use armature_azure::{AzureServices, AzureConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
init_tracing();
// Initialize Azure services
let azure = AzureServices::new(
AzureConfig::from_env()
.enable_cosmos()
.enable_blob()
.build()
).await?;
// Register in DI container
let app = Application::create::<AppModule>();
app.container().register(azure);
AzureFunctionsRuntime::new(app).run().await
}§Deployment
# Install Azure Functions Core Tools
npm install -g azure-functions-core-tools@4
# Create function app
func init --worker-runtime custom
# Add HTTP trigger
func new --template "HTTP trigger" --name api
# Deploy
func azure functionapp publish <app-name>§Azure Functions Features
This crate helps with:
- HTTP Triggers: Handle HTTP requests in Azure Functions
- Application Insights: Structured logging for monitoring
- Bindings: Access Azure services through bindings
- Configuration: Read from Azure App Configuration
Macros§
- impl_
request_ handler - Macro to implement RequestHandler for Armature applications.
Structs§
- Azure
Functions Runtime - Azure Functions runtime for Armature applications.
- Function
Config - Azure Functions configuration.
- Function
Request - Azure Functions HTTP request.
- Function
Response - Azure Functions HTTP response.
- Runtime
Config - Runtime configuration.
Enums§
- Azure
Functions Error - Azure Functions runtime errors.
Traits§
- Input
Binding - Input binding trait.
- Output
Binding - Output binding trait.
Functions§
- function_
app_ name - Get the function app name.
- function_
name - Get the function name.
- init_
tracing - Initialize tracing for Azure Application Insights.
- init_
tracing_ with_ level - Initialize tracing with a custom log level.
- invocation_
id - Get the invocation ID.
- is_
azure_ functions - Check if running in Azure Functions.
Type Aliases§
- Result
- Result type for Azure Functions operations.