Skip to content

Commit 6552692

Browse files
Merge pull request #295309 from liliankasem/liliankasem/func/cancellation
Azure Functions: Update cancellation documentation for dotnet-isolated
2 parents aea0b02 + 5f68278 commit 6552692

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

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

558+
#### Scenarios that lead to cancellation
559+
560+
The cancellation token is signaled when the function invocation is canceled. Several reasons could lead to a cancellation,
561+
and those could vary depending on the trigger type being used. Some common reasons are:
562+
563+
1. Client disconnect: the client that is invoking your function disconnected. This is most likely for HttpTrigger functions.
564+
2. Function app restart: if you, or the platform, restart (or stop) the Function App around the same time an invocation is requested.
565+
A restart can occur due to worker instance movements, worker instance updates, or scaling.
566+
- Invocations in-flight during a restart event may be retried depending on how they were triggered. Please refer to the [retry documentation](./functions-bindings-error-pages.md#retries) for further information.
567+
568+
For the isolated worker model, the host we will send the invocation through to the worker _even_ if the cancellation token was cancelled _before_ the host is able to send the invocation request to the worker.
569+
570+
If you do not want pre-cancelled invocations to be sent to the worker, you can add the `SendCanceledInvocationsToWorker` property to your `host.json` file to disable this behaviour. The following example shows a `host.json` file that uses this property:
571+
572+
```json
573+
{
574+
"version": "2.0",
575+
"SendCanceledInvocationsToWorker": "false"
576+
}
577+
```
578+
579+
> [!IMPORTANT]
580+
> Setting `SendCanceledInvocationsToWorker` to `false` may lead to a `FunctionInvocationCanceled` exception with the following log:
581+
>
582+
> `Cancellation has been requested. The invocation request with id '{invocationId}' is canceled and will not be sent to the worker`
583+
>
584+
> This occurs when the cancellation token is cancelled (as a result of one of the events described above) _before_ the host has sent
585+
> an incoming invocation request to the worker. This exception can be safely ignored and would be expected when `SendCanceledInvocationsToWorker`
586+
> is `false`.
587+
558588
## Bindings
559589

560590
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)