Microsoft at Open Source Summit Europe 2024: Driving collaboration and innovation
Connect with other open source enthusiasts at Open Source Summit Europe 2024…
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.
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.
As another example, you can use the Dapr extension to publish and subscribe to topics between functions. Extending on Dapr state, the code below shows an example of using Dapr publish and subscribe with a JavaScript Azure Function. The Azure Function will publish data to a topic named myTopic.
Another function can now subscribe to this published topic and trigger whenever data is sent.
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.
Binding Type | Direction | Description |
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 |
Trigger Type | Description |
daprBindingTrigger | Trigger on a Dapr input binding |
daprServiceInvocationTrigger | Trigger on a Dapr service invocation |
daprTopicTrigger | Trigger on a Dapr topic subscription |
Today the extension is supported in any environment that supports running Dapr and Azure Functions host—primarily self-hosted and Kubernetes modes. Azure Functions, Dapr, and this extension are all fully open source and can be run across cloud, hybrid, and edge. You can get started with this extension on GitHub, and follow this quickstart to build a JavaScript function that uses Dapr for state management and pub/sub across functions in a Kubernetes cluster.
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.