Birdman
Birdman

Reputation: 1524

How to display verbose output in an Azure Automation Runbook?

According to the documentation, you need to have verbose logging enabled to view verbose output from an Azure runbook. If you enable this setting it displays all verbose output to the point where the output becomes useless (such at 50 lines for modules imports). This also doesn't appear to display in the "Output" window of the runbook but only in the logging tab.

So I'm stuck with producing massive amounts of verbose output which becomes useless. If I switch to using Write-Output to display to the output pane, then I have to deal with the fact that Write-Output passes objects to the pipeline, making scripts difficult and hard to manage.

Any ideas on how to log properly in Azure Runbooks? I'm getting to the point where I'm thinking writing to a logging file in a remote location (maybe a storage account) might sadly be the best option. Seems like there should be a better way to handle this.

Upvotes: 0

Views: 5108

Answers (1)

Ivan Glasenberg
Ivan Glasenberg

Reputation: 30025

Please correct me if I misunderstood you:

After enable verbose logging from "Logging and tracing" in azure portal, I can control the verbose logging via $VerbosePreference and -verbose.

The code:

enter image description here

The output:

enter image description here

and you can see that even if I set $VerbosePreference="SilentlyContinue", then I add -verbose to write-verbose, the log still can be output.

Regarding "This also doesn't appear to display in the "Output" window of the runbook", it's currently not supported for write-verbose. You can submit a request in the user voice of automation runbook.

Upvotes: 1

Related Questions