SOLVED

When monitoring the alerts of my Runbooks jobs ResultType provides wrong values.

%3CLINGO-SUB%20id%3D%22lingo-sub-294346%22%20slang%3D%22en-US%22%3EWhen%20monitoring%20the%20alerts%20of%20my%20Runbooks%20jobs%20ResultType%20provides%20wrong%20values.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-294346%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20Log%20Analytics%20records%2C%20ResutlType%20column%20shows%20%22Completed%22%20or%20%22In%20Progress%22%20instead%20of%20%22Failed%22%20for%20all%20Runbooks%20jobs%20completed%20with%20errors.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-294346%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-296583%22%20slang%3D%22en-US%22%3ERe%3A%20When%20monitoring%20the%20alerts%20of%20my%20Runbooks%20jobs%20ResultType%20provides%20wrong%20values.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-296583%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3EYou%20should%20have%20marked%20my%20reply%20as%20answer%20as%20I've%20pointed%20you%20to%20the%20documentation%20where%20this%20is%20described.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-295537%22%20slang%3D%22en-US%22%3ERe%3A%20When%20monitoring%20the%20alerts%20of%20my%20Runbooks%20jobs%20ResultType%20provides%20wrong%20values.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-295537%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20resolved%20this%20issue%20by%20adding%20the%20following%20PowerShell%20variable%20in%20my%20code%20before%20the%20cmdlet%3A%3C%2FP%3E%0A%3CP%3E%24ErrorActionPreference%20%3D%20'Stop'%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-294490%22%20slang%3D%22en-US%22%3ERe%3A%20When%20monitoring%20the%20alerts%20of%20my%20Runbooks%20jobs%20ResultType%20provides%20wrong%20values.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-294490%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3EI%20am%20not%20sure%20if%20this%20is%20a%20statement%20or%20question.%20Azure%20Automation%20periodically%20sends%20diagnostic%20logs%20to%20Log%20Analytics.%20Each%20runbook%20job%20is%20at%20some%20state%20at%20different%20periods.%20There%20could%20be%20runbooks%20that%20run%20for%20longer%20period%20and%20because%20of%20that%20Azure%20Automation%20will%20send%20the%20jobs%20of%20those%20runbooks%20as%20In%20Progress%20instead%20of%20not%20sending%20information%20for%20them%20at%20all.%20So%20for%20a%20single%20job%20you%20might%20have%20records%20for%20both%20In%20Progress%20and%20both%20Completed%20at%20some%20point%20in%20time.%20Of%20course%20the%20last%20record%20is%20the%20last%20state%20of%20the%20runbook%20job.%20Keep%20in%20mind%20that%20for%20a%20single%20runbook%20you%20might%20have%20multiple%26nbsp%3B%20job%20instances%20and%20they%20all%20be%20in%20different%20states%20depending%20on%20their%20end%20result.%20Also%20if%20you%20are%20familiar%20with%20Azure%20Automaiton%20runbooks%20you%20have%20to%20explicit%20put%20in%20your%20code%20if%20errors%20should%20result%20in%20the%20runbook%20failing%20or%20just%20continuing%20by%20just%20logging%20the%20errors%20but%20the%20end%20runbook%20will%20be%20marked%20completed.%20The%20same%20behavior%20is%20for%20warnings.%3C%2FP%3E%0A%3CP%3EMore%20information%20on%20Azure%20Automation%20diagnostic%20logs%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-manage-send-joblogs-log-analytics%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-manage-send-joblogs-log-analytics%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMore%20information%20on%20runbook%20error%20handling%20here%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-runbook-output-and-messages%23message-streams%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fautomation-runbook-output-and-messages%23message-streams%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

In Log Analytics records, ResutlType column shows "Completed" or "In Progress" instead of "Failed" for all Runbooks jobs completed with errors.

3 Replies

Hi,

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:

https://docs.microsoft.com/en-us/azure/automation/automation-manage-send-joblogs-log-analytics

 

More information on runbook error handling here:

https://docs.microsoft.com/en-us/azure/automation/automation-runbook-output-and-messages#message-str...

 

best response confirmed by Antoineb (Microsoft)
Solution

I have resolved this issue by adding the following PowerShell variable in my code before the cmdlet:

$ErrorActionPreference = 'Stop'

Hi,

You should have marked my reply as answer as I've pointed you to the documentation where this is described.