Azure Scheduler job dependency

Gunasekaran X Krishnan 1 Reputation point


We have a recurring job scheduled using azure automation account for every 2Hrs. We don't want multiple jobs run at sametime, basically if a job is running, the next one should not start until the running one is complete even after the 2Hr window.

Is it possible to add dependency in the schedule to have the job start only if the current job is completed.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,192 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 103.8K Reputation points MVP

    Hi @Gunasekaran X Krishnan ,

    this should be possible.

    With the cmdlet Get-AzAutomationJob it should be possible to query the Azure Automation jobs. Based on the result of the job list and status of the jobs in the lists check if a job of the runbook is still running.

    Just a draft of the runbook:

    • Schedule the runbook every 2 hours
    • Check if another job instance of the runbook is still running
    • If "yes" = End/exit
    • if "no" = go further and do the magic
    • Check at the end if the 2 hours schedule is breached (runbook runs longer than 2 hours)
    • if "yes" = start another job instance ( Start-AzAutomationRunbook )
    • if "no" = end (wait for the next schedule interval)

    This should be doable with PowerShell.


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Andreas Baumgarten

    0 comments No comments

  2. sadomovalex 3,631 Reputation points

    just as idea: is it possible to do the same task using Azure web job? They also can run by scheduler (set via cron expression) and in this case nothing should be done for ensuring that only one instance runs at a time - this is by design for web jobs. They use lock files to prevent 2nd instance of the same web job to start until 1st instance will finish.

    0 comments No comments