I have following scenario. Runbook in Azure automation account running some sort of actions.
Each action should log some message. After all steps are done, runbook gathers logs from Log Analytics Workspace and send them by email.
In runbook I am using three commands for message output:
- Write-Output - for information message level
- Write-Warning - for warning message level
- Write-Error - for error message level
In runbook’s job output I can see output as I would expect:
Now, if I am going to Log Analytics Workspace and filter that job’s messages, I can see same output as on job’s all logs page but in case of error message (Write-Error) if prints whole script not just message specified
Here is sample how message might look like in script
The problem is, that once it hits the error message, in log appears whole script (in column RunbookMessage)
Does anyone tried to solve same output problem?
So far I come up with solution to use only Write-Output and customize the message (i.e. Write-Output “ERROR - This operation failed” or Write-Output “WARNING - This operation did not finished”, etc.)
but of course would be preferred to use built-in message stream.
Thank you in advance for any ideas