Crate armature_azure_functions

Crate armature_azure_functions 

Source
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§

AzureFunctionsRuntime
Azure Functions runtime for Armature applications.
FunctionConfig
Azure Functions configuration.
FunctionRequest
Azure Functions HTTP request.
FunctionResponse
Azure Functions HTTP response.
RuntimeConfig
Runtime configuration.

Enums§

AzureFunctionsError
Azure Functions runtime errors.

Traits§

InputBinding
Input binding trait.
OutputBinding
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.