View and understand Azure automation job status

When you start a runbook in Azure Automation, it create a Azure automation job. A job is a single execution instance of a runbook. A job is then assigned to a Azure worker process, which then executes it. When you view the list of runbooks in the Azure portal, it will list the status of the last job that was started for each runbook.You can view the list of jobs for each runbook in order to track the status of each job.

Below command get the last job ran for a Azure automation runbook  and displays its status:

$resourceGroupName = "enggdevsoutheastasia"
$automationAccountName = "AzureAutomation"
$runbookName = "start-azurevms"
$job = (Get-AzureRmAutomationRunbook -automationAccountName $automationAccountName `
 -resourceGroupName $resourceGroupName | sort LastModifiedDate desc)[0]

These 2 diagrams illustrate the lifecycle of jobs in Azure:

Lifecycle of an Azure automation job for a graphical runbook
Lifecycle of azure automation job for PoweShel workflow runbook
Lifecycle of Azure automation job for a PowerShell workflow runbook

Below table lists descriptions for various job statues:

The following table describes the different statuses that are possible for a job.

Status Description
Completed The job completed successfully.
Failed For Graphical and PowerShell workflow runbook type,  the runbook failed to compile. For PowerShell script runbook type,  the runbook failed to start or the job encountered an exception.
Failed, waiting for resources The job failed because it reached the fair share limit three times and started from the same checkpoint or from the start of the runbook each time.
Queued The job is waiting for resources on an Automation worker to come available so that it can be started.
Starting The job has been assigned to a worker, and the system is in the process of starting it.
Resuming The system is in the process of resuming the job after it was suspended.
Running The job is running.
Running, waiting for resources The job has been unloaded because it reached the fair share limit. It will resume shortly from its last checkpoint.
Stopped The job was stopped by the user before it was completed.
Stopping The system is in the process of stopping the job.
Suspended The job was suspended by the user, by the system, or by a command in the runbook. A job that is suspended can be started again and will resume from its last checkpoint or from the beginning of the runbook if it has no checkpoints. The runbook will only be suspended by the system in the case of an exception. By default, ErrorActionPreference is set to Continue meaning that the job will keep running on an error. If this preference variable is set to Stop then the job will suspend on an error.
Suspending The system is attempting to suspend the job at the request of the user. The runbook must reach its next checkpoint before it can be suspended. If it has already passed its last checkpoint, then it will complete before it can be suspended.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s