Description
This issue is specific to PowerShell scripts running in Azure Automation. Azure Automation run PowerShell/PowerShell Workflow scripts at scale for customers.
Recently, we have observed issues while running PowerShell automation job which uses Disable-AzContextAutosave cmdlet.
After { Disable-AzContextAutosave -Scope Process } cmdlet, logging of warnings in subsequent cmdlets are skipped.
Steps to reproduce
Running the below PS cmdlets in automation PowerShell runbook. QuickStart on how to create and run an Automation runbook.
Write-Warning "Before Disable-AzContextAutosave"
$null = Disable-AzContextAutosave -Scope Process
Write-Warning "After Disable-AzContextAutosave"
Output of the script
WARNING: Before Disable-AzContextAutosave
Note that the later Warning is not getting logged.
Environment data
Name Value
---- -----
PSVersion 5.1.15063.726
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.726
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module versions
Directory: C:\Modules\User
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.7.4 Az.Accounts {Disable-AzDataCollection, Disable-AzContextAutosave, Enabl...
Script 3.5.0 Az.Compute {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAva...
Script 1.12.0 Az.Resources {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRo...
Script 1.13.0 Az.Storage {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStora...
Script 21.1.18218 SqlServer {Add-RoleMember, Add-SqlAvailabilityDatabase, Add-SqlAvaila...
Directory: C:\Modules\Global
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.1.0.0 AuditPolicyDsc
Debug output
Set $DebugPreference='Continue' did not log any extra stream in Automation Output.
Few findings while investigating the issue –
- Only warning streams are skipped – writing errors are output work as expected.
- If AzureRm.Profile module is used instead of Az.Accounts, Disable-AzureRmContextAutosave does not skip the warnings. It works as expected.
- $warningpreference parameter is not modified after running the {Disable-AzContextAutosave -Scope Process } cmdlet. It is set to ‘Continue’.
Automation service do not have any special logic for modifying and controlling flow of any kind of output streams whether it is verbose, error or warning. Also since, everything works fine with AzureRm.Profile module in automation – we were wondering whether { Disable-AzContextAutosave -Scope Process } cmdlet from Az.Accounts module does something which could interfere with warning logs under any special circumstances.
Error output
Not Applicable.
Description
This issue is specific to PowerShell scripts running in Azure Automation. Azure Automation run PowerShell/PowerShell Workflow scripts at scale for customers.
Recently, we have observed issues while running PowerShell automation job which uses Disable-AzContextAutosave cmdlet.
After { Disable-AzContextAutosave -Scope Process } cmdlet, logging of warnings in subsequent cmdlets are skipped.
Steps to reproduce
Running the below PS cmdlets in automation PowerShell runbook. QuickStart on how to create and run an Automation runbook.
Output of the script
WARNING: Before Disable-AzContextAutosaveNote that the later Warning is not getting logged.
Environment data
Module versions
Debug output
Set $DebugPreference='Continue' did not log any extra stream in Automation Output.
Few findings while investigating the issue –
Automation service do not have any special logic for modifying and controlling flow of any kind of output streams whether it is verbose, error or warning. Also since, everything works fine with AzureRm.Profile module in automation – we were wondering whether { Disable-AzContextAutosave -Scope Process } cmdlet from Az.Accounts module does something which could interfere with warning logs under any special circumstances.
Error output
Not Applicable.