-
Hey there Quick question: I used to have a cancellation token in my durable entity, retrieved by IDurableEntityContext.FunctionBindingContext.CancellationToken to enable graceful shutdown e.g. when the function app scales in. How do I get a cancellation token in my entities in isolated model? Is there something I could get via Dependency Injection which is not documented? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 14 replies
-
Adding @jviau who will probably know this better than me, but I suspect the equivalent of Example, from an activity function: [Function(nameof(SayHello))]
public static string SayHello(
[ActivityTrigger] string cityName,
FunctionContext funcContext)
{
funcContext.CancellationToken.ThrowIfCancellationRequested();
return $"Hello, {cityName}!";
} |
Beta Was this translation helpful? Give feedback.
-
After digging into the code for isolated entities I have a suggestion:
Shall I open an issue or transfer this discussion to an issue? |
Beta Was this translation helpful? Give feedback.
-
As an alternative, if the function context would be available by dependency injection, this would help too. |
Beta Was this translation helpful? Give feedback.
-
Anyways, I would like to get an educated advice: |
Beta Was this translation helpful? Give feedback.
-
Edit: I opened another discussion for this, see #2791 (comment) |
Beta Was this translation helpful? Give feedback.
You can manually construct your entity and then dispatch to it. https://github.com/Azure/azure-functions-durable-extension/blob/dev/src/Worker.Extensions.DurableTask/TaskEntityDispatcher.cs#L36
For DI'ing
FunctionsContext
directly in, you can also follow this: https://gist.github.com/dolphinspired/796d26ebe1237b78ee04a3bff0620ea0