[−][src]Crate azure_functions
Azure Functions for Rust
The Azure Functions for Rust crate supports creating Azure Functions with Rust.
The following Azure Functions trigger bindings are supported:
- Blob trigger
- Cosmos DB trigger
- Durable Activity trigger
- Durable Orchestration trigger
- Event Grid trigger
- Event Hub trigger
- Generic trigger
- HTTP trigger
- Service Bus trigger
- Queue trigger
- Timer trigger
The following Azure Functions input bindings are supported:
- Blob input
- Cosmos DB input
- Durable orchestration client input
- Generic input
- SignalR connection info input
- Table input
The following Azure Functions output bindings are supported:
- Blob output
- Cosmos DB output
- Event Hub output
- Generic output
- HTTP output
- Queue output
- SendGrid email message output
- Service Bus output
- SignalR group action output
- SignalR message output
- Table output
- Twilio SMS message output
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
Create a HTTP-triggered function:
$ cargo func new http -n hello
This generates src/functions/hello.rs
with the following contents:
use azure_functions::{ bindings::{HttpRequest, HttpResponse}, func, }; #[func] pub fn hello(req: HttpRequest) -> HttpResponse { "Hello from Rust!".into() }
Azure Functions are implemented by applying a #[func]
attribute to a Rust function.
Run the application with cargo func run
:
$ cargo func run
The above Azure Function can be invoked with http://localhost:8080/api/hello
.
The expected response would be Hello from Rust!
.
Re-exports
pub use azure_functions_codegen::export; |
pub use azure_functions_codegen::func; |
pub use azure_functions_shared::rpc; |
Modules
bindings | Module for Azure Functions bindings. |
blob | Module for blob storage types. |
context | Module for function invocation context. |
durable | Module for Durable Functions types. |
event_hub | Module for Event Hub types. |
generic | Module for generic Azure Function bindings. |
http | Module for HTTP types. |
send_grid | Module for SendGrid types. |
signalr | Module for SignalR types. |
timer | Module for timer types. |
Functions
worker_main | The main entry point for the Azure Functions for Rust worker. |
worker_main_with_extensions | The main entry point for the Azure Functions for Rust worker. |