azure-functions crate has a dependency on the
grpcio crate that
uses CMake to build and link against the gRPC
CMake must be installed and on the
PATH to be able to use Azure Functions for Rust.
Install CMake from the Windows installer.
The easiest way to install CMake on macOS is with Homebrew:
$ brew install cmake
Use your distro's package manager to install a
cmake (or similar) package.
For example on Debian/Ubuntu:
$ apt-get install cmake
Install version 2 or higher of the Azure Functions Core Tools.
If you are on Windows, you must add
func.exe is located) to the
PATH environment variable.
Install the Azure Functions for Rust SDK using
$ cargo install azure-functions-sdk
This installs a new cargo command named
func that can be used to create and run new
Azure Functions applications.
cargo func new-app command to create a new Azure Functions application:
$ cargo func new-app hello
This will create a new application in the
./hello directory with a module named
functions where the exported Azure Functions are expected to be placed.
cargo func new command to create a new HTTP-triggered Azure Function named
$ cargo func new http -n hello
The source for the function will be in
To build your Azure Functions application, just use
$ cargo build
If you are using a nightly compiler, you can enable improved error messages during compilation.
Add the following to your
[features] unstable = ["azure-functions/unstable"]
Build your application:
$ cargo build --features unstable
This enables Azure Functions for Rust to emit diagnostic messages that will include the position of an error within an attribute.
To build and run your Azure Functions application, use
cargo func run:
$ cargo func run
cargo func run command builds and runs your application locally using the Azure
Function Host that was
installed by the Azure Functions Core Tools.
By default, the host will be configured to listen on
hello function added previously, it can be invoked from
This will enable a
Debug launch configuration that will build and run your
application locally before attaching the
lldb debugger to the Rust worker process.
In the future, there will be a
cargo func deploy command to deploy the Azure
Functions application directly to Azure.
Until that time, you must manually build and push the Docker image to a repository that can be accessed by Azure.
Note: this requires Docker that is at least 18.06 for the experimental BuildKit support.
To enable the BuildKit support, set the
1 before running
Start by building your image with
docker build -t $TAG_NAME .:
$ docker build -t $TAG_NAME .
$TAG_NAME is the tag name to use (e.g.
docker push to push the image to a repository that is accessible to Azure
$ docker push $TAG_NAME
Create the Function App in Azure using the "Linux (Preview)" OS. Under the "Publish" setting, select "Docker Image".
From the "Configure Container" section, select the repository and enter the image you pushed.
That's it! Once the Functions App starts in Azure, you should be able to view the functions and run them.