Azure / Azure/azure-powershell

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"

Open
#24,980 9 comments 1 reaction 1 assignee Claimed by @BethanyZhou View on GitHub
Accounts bug customer-reported Investigate :mag:
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description

We are using some PowerShell scripts with the Terraform [External provider](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external#external-program-protocol), 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 "**R**etrieving.."
```
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

```PowerShell
-
```

### Environment data

```PowerShell
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

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

### Error output

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.