Repository navigation
Durable Functions v2.0.0-beta3 Release
Pre-releaseOverview
Durable Functions v2.0.0-beta3 is an incremental update from the previous beta2 release. This is the last planned pre-release for Durable Functions 2.0 and adds some new features and important bug fixes. It also includes some additional breaking changes. See below for details on what has changed in this release.
You can download the beta3 build of the Durable Functions v2 extension from nuget here: https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DurableTask/2.0.0-beta3
Major New Features
There are three main features that we've added in this release:
Durable Functions Roslyn Analyzer (#949)
We've developed a Roslyn C# analyzer that inspects your Durable Functions code for various code constraint violations and warns you if it finds any. It's based on the original Durable Functions analyzer developed by Simon Timms (@stimms), who agreed to let us build on his code to create an "official" analyzer package. The goal is to make you both more productive and more confident in the Durable Functions code that you write.
You can download this new analyzer here:
https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DurableTask.Analyzers/
The analyzer provides a variety of warnings and code-fixes across client functions, orchestrator functions, and entity functions:
A few important things to note:
-
It's our very first attempt at building an analyzer, so there are going to be some bugs. Let us know if you encounter any by opening an issue.
-
For the best experience, you'll want to enable full solution analysis in your Visual Studio settings. This can be done in Tools -> Options -> Text Editor -> C# -> Advanced --> "Enable full solution analysis":
- The analyzer will flag any direct method calls made by your orchestrator function. Direct method calls are not bad, but we require that these methods are decorated with a newly introduced
[Deterministic]attribute so that the analyzer knows to check them for correctness.
The following example demonstrates how the [Deterministic] attribute is used:
[FunctionName("MyOrchestrator")]
public static async Task MyOrchestrator([OrchestrationTrigger] IDurableOrchestrationContext context)
{
object input = context.GetInput<object>();
object result1 = DirectCall(context, input);
object result2 = await DirectAsyncCall(context, result1);
object result3 = await context.CallActivityAsync<object>("MyActivity", result2);
// ...
}
[Deterministic]
private static object DirectCall(IDurableOrchestrationContext context, object input)
{
return IndirectCall(); // call another method, which must also be analyzed
}
[Deterministic]
private static object IndirectCall()
{
// ... some inline code goes here
}
[Deterministic]
private static async Task<object> DirectAsyncCall(IDurableOrchestrationContext context, object result1)
{
// ... this could be some wrapper around an activity function call, a durable timer, external event, etc.
}
[FunctionName("MyActivity")]
public static object MyActivity([ActivityTrigger] IDurableActivityContext context)
{
// ... a normal activity function. This is not required to have the [Deterministic] attribute.
}Note that only methods which have an orchestrator function in the callstack are required to have the [Deterministic] attribute. Activity functions and client functions have no such requirement.
Durable Entities in JavaScript (#940 and Azure/azure-functions-durable-js#102)
As part of this release, we have also added support for Durable Entities written in JavaScript. This new support exists starting in the v1.3.0 release on npm.org. Here is an example "Counter" entity written in JavaScript:
const df = require("durable-functions");
module.exports = df.entity(function(context) {
let currentValue = context.df.getState(() => 0);
switch (context.df.operationName) {
case "add":
const amount = context.df.getInput();
currentValue += amount;
break;
case "reset":
currentValue = 0;
break;
case "get":
context.df.return(currentValue);
break;
}
context.df.setState(currentValue);
});Similarly, orchestrator functions written in JavaScript can invoke durable entities:
const df = require("durable-functions");
module.exports = df.orchestrator(function*(context){
const entityId = new df.EntityId("CounterEntity", "myCounter");
currentValue = yield context.df.callEntity(entityId, "get");
if (currentValue < 10) {
yield context.df.callEntity(entityId, "add", 1);
}
});Durable HTTP in JavaScript (#953 and Azure/azure-functions-durable-js#97)
Also included in this release is support for Durable HTTP in JavaScript. Durable HTTP was first introduced as a new feature in beta2 for .NET and now we've made it available in JavaScript, including built-in support for leveraging Azure Managed Identities. Here is a sample JavaScript function which calls the Azure Resource Manager REST API to get a list of Azure Subscriptions available to the current user.
const df = require("durable-functions");
module.exports = df.orchestrator(function*(context) {
// get a list of the Azure subscriptions that I have access to
var res = yield context.df.callHttp(
"GET",
"https://management.azure.com/subscriptions?api-version=2019-06-01",
undefined, // no request content
undefined, // no request headers (besides auth which is handled by the token source)
df.ManagedIdentityTokenSource("https://management.core.windows.net"));
return res;
});Breaking Changes
There were a couple breaking changes to Durable Entities introduced in this release.
IDurableEntityContext.IsNewlyConstructedhas been renamed toHasState.IDurableEntityContext.DestructOnExit()has been renamed toDeleteState().
Additional Updates
- Fix a bug related to using default state initialization + primitives (#959)
- Simplify entity state handling (#957)
- Resolve custom lifecycle helper using Dependency Injection (#921) - contributed by Tatsuro Shibamura (@shibayan)
- Fix bug in sorting of lock messages (#955)
- Overhaul exception handling for entities (#946)
- Added
[Deterministic]attribute for use with the Roslyn analyzer (#950) - Support
StartNewOrchestrationfrom within orchestrations and entities (#917) - Implementing support for explicit interfaces (and F#) (#935) - contributed by Aaron Powell (@aaronpowell)
- Fixed default durable HTTP factory registration (#924) - contributed by Tatsuro Shibamura (@shibayan)
As always, if you run into problems or have questions, please open an issue at https://github.com/Azure/azure-functions-durable-extension/issues/new/choose. Note that we have a separate repo that is specific to our JavaScript support, which you can find here: https://github.com/Azure/azure-functions-durable-js.
Updates to our official documentation are coming soon.

