How to set a runbook / job timeout?

fhtino 136 Reputation points
2022-04-20T08:00:01.203+00:00

Hi, I have created a runbook and successfully scheduled it to run every day. Now, I would like to set a timeout on the runbook or scheduled job to kill my job in case it is still running after x minutes. Is it possible?
I know that I could do something inside the powershell script but I would prefer an external system that kill my job if its running time exceeded a value.

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

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 17,401 Reputation points
    2022-05-11T13:50:16.143+00:00

    @fhtino I understand you want to terminate scheduled jobs if it exceeds specified time. You can create PowerShell Script which retrieves the job information. For this, you can use Get-AzAutomationJob. Retrieve the difference between current time and start time and compare it to specified time. If it exceeds, then you can stop the job using Stop-AzAutomationJob or Suspend-AzAutomationJob.