Start background service with schedule and on events

Vaishnavi 546 Reputation points

I have a background worker who listens for messages on a service bus (Azure Service bus).
Each message represents an async task that the service should perform, however in the event that no events reach the bus, I'd like to automatically start the service every day.

Currently, the service bus is triggered by user events generated by various APIs.

This works fine, but who should set a schedule for my service?

Of course, I could construct a second service that sends a message to the bus once a week, but having a service dedicated to this activity feels like overkill.

I'm wondering whether there's a better way to go about doing this. For me, even an Azure Function seems excessive...

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
339 questions
No comments
{count} votes

Accepted answer
  1. MughundhanRaveendran-MSFT 11,621 Reputation points Microsoft Employee

    Hi @NFSCoder-9821 ,

    Thanks for reaching out to Q&A forum.

    Azure functions would be perfect fit as you can create a service bus triggered function and a timer triggered function inside the same function app. However you feel it is excessive. Another option that I can think of is to use the Azure webjobs that can run in the App services. You can have timer triggered webjobs and use webjob sdk to trigger it whenever there is a message in the service bus.

    Sheduled webjobs :

    Service bus triggered webjobs :

    I hope this helps!

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    No comments

0 additional answers

Sort by: Most helpful