Skip to content

Commit 48f5a0d

Browse files
authored
Update cancellation docs
1 parent d8e5782 commit 48f5a0d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

articles/azure-functions/dotnet-isolated-process-guide.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,33 @@ public async Task HandleCancellationCleanup(
555555
}
556556
```
557557

558+
#### Scenarios that lead to cancellation token being cancelled
559+
560+
The cancellation token is cancelled when any of the following events occur:
561+
562+
1. Client Disconnects: the client that is invoking your function disconnected. This is most likely for HttpTrigger functions.
563+
2. Function App Restarts: if you or the platform restart your Function App around the same time an invocation is requested. This should not have any impact as when the host starts back up it will retry the request.
564+
- Restarts could occur due to worker instance movements, worker instance updates, or scaling
565+
566+
For the dotnet-isolated worker, the host we will send the invocation through to the worker _even_ if the cancellation token was cancelled _before_ we get to sending the invocation request to the worker.
567+
568+
If you do not want pre-cancelled invocations to be sent to the worker, you can add the following property to your host.json file to disable this behaviour.
569+
570+
```json
571+
{
572+
"version": "2.0",
573+
"SendCanceledInvocationsToWorker": "false"
574+
}
575+
```
576+
577+
> [!IMPORTANT]
578+
> Warning: Setting `SendCanceledInvocationsToWorker` to `false` may lead to a `FunctionInvocationCanceled` exception with the following log:
579+
>
580+
> `Cancellation has been requested. The invocation request with id '{invocationId}' is canceled and will not be sent to the worker`
581+
>
582+
> This occurs when the cancellation token is cancelled (via the events defined above), but the host did not send the invocation to the worker because the cancellation token was cancelled
583+
> _before_ we send the invocation to the worker, and can be controlled by the `SendCanceledInvocationsToWorker` property.
584+
558585
## Bindings
559586

560587
Bindings are defined by using attributes on methods, parameters, and return types. Bindings can provide data as strings, arrays, and serializable types, such as plain old class objects (POCOs). For some binding extensions, you can also [bind to service-specific types](#sdk-types) defined in service SDKs.

0 commit comments

Comments
 (0)