Crate azure_functions[][src]

Azure Functions for Rust

The Azure Functions for Rust crate supports writting Azure Functions in Rust.

The following Azure Functions trigger bindings are supported:

The following Azure Functions output bindings are supported:

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


Start by creating a new binary package:

$ cargo new --bin example

Edit Cargo.toml to include the following dependencies:

azure-functions = "0.1.3"
log = "0.4.2"

Azure Functions are implemented by applying a trigger attribute to a Rust function.

For example, let's create src/ that implements a HTTP triggered function by applying the func attribute:

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

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

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

Replace the contents of src/ with the following to register the function with the Azure Functions Host:

This example is not tested

extern crate log;
extern crate azure_functions;

mod greet;

// The main! macro generates an entrypoint for the binary
// Expects a list of Azure Functions to register with the Azure Functions host

Run the application with the --create <root> option, where <root> is the path to the desired Azure Functions application root directory:

$ export AzureWebJobsScriptRoot=path-to-root
$ cargo run -q -- --create $AzureWebJobsScriptRoot

Run the Azure Functions Host:

$ cd azure-functions-host/src/WebJobs.Script.WebHost
$ dotnet run

The above Azure Function can be invoked with http://localhost:5000/api/greet?name=John.

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


pub use azure_functions_codegen::func;
pub use azure_functions_codegen::main;



Module for Azure Functions bindings.


Module for HTTP-related types.



Represents context about an Azure Function invocation.