We’re excited to announce a new extension for Azure Functions that lets a function seamlessly interact with Dapr for building cloud-native applications. Azure Functions provides an event-driven programming model and Dapr provides a set of essential cloud-native building blocks. With this new extension, you can now bring both together for serverless and event-driven apps that can use the growing set of capabilities Dapr provides. Developers, teams, and organizations can use these tools to build functions that use a powerful set of capabilities with little code. You can get started today with the extension, which is fully open source on GitHub.
Currently, this extension is focused on being used with the Azure Functions runtime hosted in Kubernetes or IoT Edge and is not currently available in the Azure Functions hosting plans.
Late last year, Microsoft announced Dapr, a distributed application runtime. Dapr provides a set of cloud-native building blocks including state management, service invocation, publish and subscribe, distributed tracing, and more. Dapr runs as a sidecar to any application to provide these capabilities across cloud and edge, integrating with any programming model or framework, including Express, Flask, ASP.NET, or Functions.
Azure Functions, in addition to the serverless offering within the Azure cloud, provides an event-driven runtime and programming model for those apps. Azure Functions enables you to write event-driven code that can trigger and scale on events, with a number of out of the box triggers and bindings to push your data. It’s a purpose-built runtime for event-driven applications, providing capabilities and tooling to run these apps anywhere.
Azure Functions and Dapr working together
This new extension allows you to more easily pair the Azure Functions programming model with capabilities from Dapr. For example, you may wish to keep some persistent and flexible state alongside your function. You can now create and retrieve state managed by Dapr directly within the functions programming model like below:
This state example would work alongside a Dapr persistent state store, deployed as a Dapr component, which can be interchanged for any of the many Dapr state stores.
Publish and subscribe between Azure Functions
Another function can now subscribe to this published topic and trigger whenever data is sent.
Dapr extension bindings and triggers
These are a couple of examples of how to use the Dapr extension. This extension has support for triggering functions on a Dapr service invocation, pub/sub events, or Dapr input/output bindings. It provides integration to use Dapr state, secrets, topics, and bindings from directly in your function code. The Dapr SDKs and contracts are managed completely through the Azure Functions host, enabling developers to surface these capabilities quickly and efficiently. Below is the list of bindings and triggers available.
|daprState||Input||Pull in Dapr state for an execution|
|daprSecret||Input||Pull in Dapr secrets for an execution|
|daprState||Output||Save a value to Dapr state|
|daprInvoke||Output||Invoke another Dapr app|
|daprPublish||Output||Publish a message to a Dapr topic|
|daprBinding||Output||Send a value to a Dapr output binding|
|daprBindingTrigger||Trigger on a Dapr input binding|
|daprServiceInvocationTrigger||Trigger on a Dapr service invocation|
|daprTopicTrigger||Trigger on a Dapr topic subscription|
Give this a try!
We’d love for you to try out this Functions extension for Dapr, give feedback by raising issues in the repo and become a member of the community.
Questions or feedback about this release? Let us know in the comments below.