Skip to content

Az.Accounts 3.0.0 - How to disable output such as the announcement message "With the new Azure PowerShell login experience, you can select the subscription you want to use more easily" #24980

Open
@NikolaiKleppe

Description

@NikolaiKleppe

Description

We are using some PowerShell scripts with the Terraform External provider, which requires that anything sent to the output stream must be JSON

This new announcement (and the "Retrieving subscriptions for the selection" text) is captured and crashes the pipeline and I haven't figured out how to disable it.

Authentication is by Service Principal so this shouldn't be relevant anyway, but I've disabled the LoginExperienceV2 just in case and that doesn't do anything either.

Not sure if this issue should be for Azure PowerShell or the Terraform team.

Example:

$azConfig = Set-AzConfig -LoginExperienceV2 'Off' -EnableLoginByWam $false -DisplaySurveyMessage $false -DisplayRegionIdentified $false -CheckForUpgrade $false -WarningAction Ignore | Out-Null

$con = Connect-AzAccount -ServicePrincipal -TenantId $tenantId -Credential $credential -Subscription $subscriptionId -WarningAction Ignore | Out-Null

Then in our pipeline agent I see this is captured:

Retrieving subscriptions for the selection...
[Announcements]
With the new Azure PowerShell login experience, you can select the subscription you want to use more easily. Learn more about it and its configuration at https://go.microsoft.com/fwlink/?linkid=2271909.

If you encounter any problem, please open an issue at: https://aka.ms/azpsissue

Notice the reference to the R character from the pipeline output, which is from "Retrieving.."

The data source received unexpected results after executing the program.
│ 
│ Program output must be a JSON encoded map of string keys and string values.
│ 
│ If the error is unclear, the output can be viewed by enabling Terraform's
│ logging at TRACE level. Terraform documentation on logging:
│ https://www.terraform.io/internals/debugging
│ 
│ Program: /usr/bin/pwsh
│ Result Error: invalid character 'R' looking for beginning of value

Issue script & Debug output

-

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Ubuntu 20.04.6 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     3.0.0                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}

Error output

No response

Metadata

Metadata

Assignees

Labels

AccountsIssues in Az.Accounts except authentication relatedInvestigate 🔍bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reported

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions