Reputation: 1524
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.
-Verbose
switch to a Write-Verbose
cmdlet. In normal PowerShell, this will produce verbose output no matter what the $VerbosePreference
is set to. This would have been a solution to only explicitly printing certain verbose output, but it appears to be 'all or nothing' in runbooks.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
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:
The output:
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