Azure / Azure/azure-powershell

Connect-AzAccount does not correctly set the name of the environment

Open
#28,995 2 comments 0 reactions 0 assignees View on GitHub
Azure PS Team bug customer-reported Tracking
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description

I have some additional environments like for example:

$azEnv = (Get-AzEnvironment -Name AzureCloud)
$azEnv.Name = "$"
$azEnv.ResourceManagerUrl = "https://centraluseuap.management.azure.com/"
$azEnv | Add-AzEnvironment

If i start with no context and do Connect-AzAccount -Environment CentralUsEuap

Image

Its all good. But then i do Connect-AzAccount -Environment AzureCloud

Image

And the resource manager url has changed, yet the name of the environment has remained the same...

The inverse is also true, i can start with AzureCloud and then swap, and the Name will stay as AzureCloud instead of swapping to CentralUSEuap

### Issue script & Debug output

```PowerShell
N/A
```

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 5.1.20348.4294
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.20348.4294
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```

### Module versions

```PowerShell
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 5.3.0 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear...
Script 6.4.0 Az.KeyVault {Add-AzKeyVaultCertificate, Add-AzKeyVaultCertificateConta...
Script 7.22.0 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Add-Az...
Script 8.1.1 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDeny...
```

### Error output

```PowerShell

```

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.