Dec 03 2018
- last edited on
Apr 07 2022
In Log Analytics records, ResutlType column shows "Completed" or "In Progress" instead of "Failed" for all Runbooks jobs completed with errors.
Dec 03 2018 11:10 PM
I am not sure if this is a statement or question. Azure Automation periodically sends diagnostic logs to Log Analytics. Each runbook job is at some state at different periods. There could be runbooks that run for longer period and because of that Azure Automation will send the jobs of those runbooks as In Progress instead of not sending information for them at all. So for a single job you might have records for both In Progress and both Completed at some point in time. Of course the last record is the last state of the runbook job. Keep in mind that for a single runbook you might have multiple job instances and they all be in different states depending on their end result. Also if you are familiar with Azure Automaiton runbooks you have to explicit put in your code if errors should result in the runbook failing or just continuing by just logging the errors but the end runbook will be marked completed. The same behavior is for warnings.
More information on Azure Automation diagnostic logs:
More information on runbook error handling here:
Dec 05 2018 11:53 AMSolution
I have resolved this issue by adding the following PowerShell variable in my code before the cmdlet:
$ErrorActionPreference = 'Stop'
Dec 05 2018 10:50 PM
You should have marked my reply as answer as I've pointed you to the documentation where this is described.