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)
Regards
Andreas Baumgarten