Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many sub modules with .Autorest: Remove the use of write-information for module load message #24855

Open
mortenlerudjordet opened this issue May 8, 2024 · 1 comment
Labels
Azure PS Team customer-reported feature-request This issue requires a new behavior in the product in order be resolved. Tracking We will track status and follow internally

Comments

@mortenlerudjordet
Copy link

Description

Seems like all modules have a *.Autorest*.psm1 file (where * is sub module name) that contains the following code:
Write-Information "Loaded Module '$($accountsModule.Name)'"

For us that use the information stream for logging we get unwanted pollution of the info stream from these messages, and makes us have to use -InformationVariable infoVar on almost everything to be able to scrub the stream output:

Write-Information -MessageData "$($infoVar| Out-String -Stream | Select-String -Pattern "Loaded Module" -NotMatch)"

We use alot of ForEeach-Object -Parallel with calls to Az inside, and as this loads Az modules for each, there is a lot of pollution of the information stream from the use of Write-Information for the module load message in Az.

Please instead use, as this is often by default silenced with $VerbosePreference = "SilentlyContinue":
Write-Verbose -Message "Loaded Module '$($accountsModule.Name)'"

This is especially anoying in Azure DevOps, where the AzurePowershell task uses $InformationPreference = "Continue"

The most problematic is Az.Resources as we use this all over the place.

Issue script & Debug output

No output

Environment data

PS C:\eunomia> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.22635
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

PS C:\eunomia> Get-Module Az* | Format-Table -AutoSize

ModuleType Version PreRelease Name         ExportedCommands
---------- ------- ---------- ----         ----------------
Script     2.17.0             Az.Accounts  {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-A… 
Script     7.4.1              Az.Network   {Add-AzApplicationGatewayAuthenticationCertificate, Add-AzAp… 
Script     6.16.1             Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAs

Error output

No error output, but information stream when importing Az.Resources:
Loaded Module 'Az.Accounts'
Loaded Module 'Az.Authorization'
Loaded Module 'Az.Accounts'
Loaded Module 'Az.MSGraph'
@mortenlerudjordet mortenlerudjordet added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels May 8, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels May 8, 2024
@mortenlerudjordet
Copy link
Author

Opened PR in autorest.powershell:
Azure/autorest.powershell#1339

@isra-fel isra-fel added Azure PS Team feature-request This issue requires a new behavior in the product in order be resolved. Tracking We will track status and follow internally and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure PS Team customer-reported feature-request This issue requires a new behavior in the product in order be resolved. Tracking We will track status and follow internally
Projects
None yet
Development

No branches or pull requests

2 participants