Search code examples
azureazure-web-app-serviceazure-webjobsazure-webjobs-triggered

Azure WebJobs - run first only when second is not running


I have 2 azure triggered web jobs (time triggers), but I want to be sure, that only one is running. So, first should wait if second is running and vice versa. I don't want to combine both web jobs to one (it is developed and supported by different developers), I just want to be sure, that only one is running. How to do it?


Solution

  • Possible solution
    One possible solution would be to have all web jobs respond to something like a Semaphore in a database, Azure Storage or something like that. This way you're centralizing the value that controls the Web Job flow. Please keep in mind that this will have a performance penalty.

    My two cents
    This feels like sub-optimal design. What is the reason for not wanting to have the two web jobs running simultaneously? If the main reason is that WJ2 is dependent on WJ1, have WJ1 send a message to a queue to trigger WJ2. That way you'll be sure WJ2 will only run after WJ1 has run.