Durable entities are basically blobs of state that are stored somewhere (probably table storage). You can retrieve them and signal them with changes. They can be tied directly into standard Azure functions.
You build one as pretty much a POCO that looks like
1 | [ ] |
In this example there is one piece of state: the CurrentValue. You can retrieve it using the Get() function. Add and Reset are other signals you can send to the state.
Using it in a function involves adding a client to the signature of the function like so
1 | [ ] |
This gets you back a wrapper which includes properties like EntityExists
and EntityState
.
You can signal changes in the entity through an unfortunate interface that looks like
1 | await client.SignalEntityAsync(entityId, "Add", 1); |
That's right, strings are back in style.
Gotchas
If you create the durable entity in your function and then request it's value you at once you won't get the correct value - you just get null. I'd bet they are using some sort of outbox model that only sends data updates at the end of the function execution.