azure-functions 0.3.0

Azure Functions for Rust
azure-functions-0.3.0 doesn't have any documentation.

Azure Functions for Rust

The Azure Functions for Rust crate supports creating Azure Functions with Rust.

The following Azure Functions trigger bindings are supported:

The following Azure Functions input bindings are supported:

The following Azure Functions output bindings are supported:

Eventually more bindings will be implemented, including custom binding data.

Example

Start by installing the Azure Functions for Rust SDK:

$ cargo install azure-functions-sdk

Create a new Azure Functions for Rust application:

$ cargo func new-app hello && cd hello

Azure Functions are implemented by applying a #[func] attribute to a Rust function.

For example, let's create src/functions/hello.rs that implements a HTTP triggered function:

use azure_functions::func;
use azure_functions::bindings::{HttpRequest, HttpResponse};

#[func]
#[binding(name = "request", auth_level = "anonymous")]
pub fn hello(request: &HttpRequest) -> HttpResponse {
// Log the request on the Azure Functions Host
info!("Request: {:?}", request);

// Return a formatted string as the response
format!(
"Hello from Rust, {}!",
request.query_params().get("name").map_or("stranger", |x| x)
).into()
}

Export the Azure Function by changing src/functions/mod.rs to:

mod hello;

pub const FUNCTIONS: &[&azure_functions::codegen::Function] = azure_functions::export! {
hello::hello,
};

Run the application with cargo func run:

$ cargo func run

The above Azure Function can be invoked with http://localhost:8080/api/hello?name=Peter.

The expected response would be Hello from Rust, Peter!.