Skip to content

KeyNotFoundException when running Add-AzureAccount with no RDFE subscriptions #1654

@markcowl

Description

@markcowl

When a user is not a co-admin on any subscriptions, we throw an error like the following:

DEBUG: AzureQoSEvent: CmdletType - AddAzureAccount; IsSuccess - False; Duration - 00:00:13.2429011; Exception - System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Microsoft.Azure.Common.Authentication.ProfileClient.AddAccountAndLoadSubscriptions(AzureAccount account, AzureEnvironment environment, SecureString password)
at Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();

We should catch this condition and print a helpful error message, including the most likely cause, which is that a user really wanted to use Add-AzureRmAccount

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions