-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
Milestone
Description
To reproduce:
# First login as usual, such as Add-AzureRmAccount
Save-AzureRmProfile -Path .\armprofile.json
# Create a new PowerShell session, or use current one
Select-AzureRmProfile -Path .\armprofile.json
Select-AzureRmSubscription -SubscriptionName '<your subscription name>'
The last command above will fail with following error:
Set-AzureRmContext : Cannot retrieve the dynamic parameters for the cmdlet. Cannot process argument because the value of argument "validValues" is out of range. Change argument "validValues" to a value
that is within range.
Parameter name: validValues
Actual value was System.String[].
This is because the subscriptions list is empty or null in following code from SetAzureRMContext.cs, since we used Select-AzureRmProfile instead of Add-AzureRmAccount to login:
private RuntimeDefinedParameterDictionary CreateDynamicParameterDictionary()
{
var runtimeDefinedParameterDictionary = new RuntimeDefinedParameterDictionary();
var subscriptionIdAttributes = new Collection<Attribute>
{
new ParameterAttribute
{
ParameterSetName = SubscriptionIdParameterSet,
Mandatory = false,
HelpMessage = "Subscription",
ValueFromPipelineByPropertyName = true
},
new ValidateSetAttribute(AzureRmProfileProvider.Instance.Profile.Context.Account.GetPropertyAsArray(AzureAccount.Property.Subscriptions)),
};
Reactions are currently unavailable