Azure / Azure/azure-functions-host
Graceful shutdown of a `QueueTrigger` isolated function via `CancellationToken`
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
Hello,
In my .NET 8 `dotnet-isolated` `QueueTrigger` Azure Function, I'm unable to observe shutdown notices via the injected `CancellationToken`. This occasionally leaves my application in an unfinished, indeterminate state:
```
2024-06-05 02:31:15.782 [Information] [redacted legitimate activity, 1/250]
2024-06-05 02:31:15.860 [Information] [redacted legitimate activity, 2/250]
2024-06-05 02:31:15.866 [Information] [redacted legitimate activity, 3/250]
2024-06-05 02:31:16.233 [Information] [Microsoft.Hosting.Lifetime] Application is shutting down...
2024-06-05 02:31:31.133 [Information] [Microsoft.Hosting.Lifetime] Application started. Press Ctrl+C to shut down.
```
I opened [an issue on the `azure-functions-dotnet-worker` repo](https://github.com/Azure/azure-functions-dotnet-worker/issues/2510) about a month ago, but I haven't received any response.
I describe the issue fully over there, and I also have a [full reproduction here](https://github.com/jonsagara/AzureFunctionQueueTriggerCancellationTokenTest). It shows that the `CancellationToken` works with .NET 6 in-process, but not with .NET 6 or .NET 8 isolated.
Will you please take a look at the issue and, if appropriate, move it to this repository?
Thank you,
Jon
#### Expected behavior
A `dotnet-isolated` `QueueTrigger` function should be able to observe a `CancellationToken` and gracefully shutdown.
#### Actual behavior
A `dotnet-isolated` `QueueTrigger` function cannot observe a `CancellationToken` and gracefully shutdown.
Contributor guide
Research direction
Start by reading the linked azure-functions-dotnet-worker issue #2510 and the full reproduction repository, comparing the .NET 6 in-process behavior with the .NET 6 and .NET 8 isolated cases. Determine whether the missing CancellationToken shutdown behavior belongs in this repository or the worker repository; done means the ownership and required fix are established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100