Skip to content

Fix PublicEnvironments initialization when context is autosaved #5727

@gsacavdm

Description

@gsacavdm

Description

Running Enable-AzureRmContextAutosave breaks support for sovereign clouds. After running that command, Get-AzureRmEnvironment returns no results and Login-AzureRmAccount -Environment AzureUSGovernment errors out with "Unable to find environment with name 'AzureUSGovernment'"

Script/Steps for Reproduction

# Show all environments. This works fine if ContextAutoSave is not enabled
Get-AzureRmEnvironment | ft

# Try to log in, this will prompt correctly, cancel out from this dialog
Login-AzureRmAccount -Environment AzureUSGovernment

# Now enable auto save
Enable-AzureRmContextAutosave

# No environments are show anymore
Get-AzureRmEnvironment | ft

# Login fails
Login-AzureRmAccount -Environment AzureUSGovernment

Module Version

5.4.1

Environment Data

Name Value
PSVersion 5.1.16299.248
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.248
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

contextautosave_fail

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions