question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CancellationToken never cancelled in Triggered WebJob

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
gidziucommented, Apr 14, 2020

same issue, is anyone working on this? Probably it is better to stay away from thsi webjob business

0reactions
msftbot[bot]commented, Feb 19, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found