CancellationToken never cancelled in Triggered WebJob
See original GitHub issueI’m having a triggered webjob which executes some async
actions (Graph API calls) in a loop.
When trying to use the cancellationToken
to handle application shutdown, it seems it’s never set to cancelled.
My webjob is initiated with:
using var host = hostBuilder.Build();
await host.StartAsync();
var jobHost = host.Services.GetService<IJobHost>();
await jobHost.CallAsync(nameof(Functions.RunBoxSync));
await host.StopAsync();
and Functions.RunBoxSync is defined as such:
public async Task RunBoxSync(ILogger log, CancellationToken cancellationToken)
But, as said, the cancellationToken is never cancelled.
How do I pass the correct cancellationToken to the Function?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Continuous WebJobs and CancellationToken
If a new message is written to the service bus queue, does this message trigger a new job despite the fact that a...
Read more >How to use the WebJobs SDK - Azure App Service
The Timeout attribute causes a function to be canceled if it doesn't finish within a specified amount of time. In the following example,...
Read more >Avoid un-stoppable webjobs using JobHost - Stuff & Tacos
cancellationToken.Register() has to call host.Stop() in order to go through RunAndBlock(). in your log stream, you will now get ...
Read more >WebJobs Graceful Shutdown - Blog.Amit Apple
Amit - Do the cancellation token and the graceful shutdown process apply in the case where you have a continuous queue-triggered webjob (for ......
Read more >Azure WebJobs In .NET Core – Part 4
This is part 4 of a series on getting up and running with Azure WebJobs in .NET Core. If you are just joining...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
same issue, is anyone working on this? Probably it is better to stay away from thsi webjob business
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.