azure-functions-sdk 0.4.0

Azure Functions for Rust Developer Tools
azure-functions-sdk-0.4.0 is not a library.

Azure Functions for Rust SDK

The Azure Functions for Rust SDK is a cargo extension for creating Azure Functions applications

Start by installing the Azure Functions for Rust SDK

$ cargo install azure-functions-sdk

Next, create a new Azure Functions application:

$ cargo func new-app 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 function in src/functions/mod.rs:

use azure_functions::export;

export!{
  hello
}

Run the application:

$ cargo func run

Now invoke the function using cURL from a different terminal session:

$ curl http://localhost:8080/api/hello\?name\=John
Hello from Rust, John!