Add-AzureAccount: The index was out of range. Must be non-negative and smaller than the size of the collection

On August 4, a new version of the Azure powershell module (0.8.7.1) was released. It has the ability to create credentials, which can then be passed to the Add-AzureAccount function. Add-AzureAccount allows you to use your account to work in your current PowerShell session.

$userName = "buildmaster@someaccount.onmicrosoft.com"
$securePassword = ConvertTo-SecureString -String "somepassword." -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($userName, $securePassword)

Add-AzureAccount -Credential $cred

This allowed me to get away from the popup or mess with the settings file.

He seems to have stopped working! Both Add-AzureAccount (which pops up) and credentials. Now they return an index out of range.

Add-AzureAccount : Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
At S:\QA\Azure Scripts\cm-azure-helpers.psm1:1128 char:5
+     Add-AzureAccount
+     ~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzureAccount], ArgumentOutOfRangeException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount

Fiddler , OAuth , , . . 302 , , . , , .

- Add-AzureAccount, ? - ?

-

, , . , ( , ), .

:

PS: 3 Azure Module: 0.8.6 PS: 3 : 0.8.7 PS: 4 Azure Module: 0.8.6 PS: 4 Azure Module: 0.8.7

Add-AzureAccount flow and version info

+4
4

, , ( , , :))

, , / . ​​ " ".

"get-azuresubscription -default", , . "" , "remove-azuresubscription".

, , " " PS.

Azure PowerShell, . , , , .

+1

, , ( PowerShell /, 1 GET/subscriptions.

, , - . , , , , ..

+1

I recently had a similar problem. The “fix” was for me to delete files in C: \ Users [username] AppData \ Roaming \ Windows Azure Powershell (especially the WindowsAzureProfile.xml file). The next time I started Add-AzureAccount, the necessary files were created, and everything was fine.

0
source

Please, use:

Add-AzureRmAccount -SubscriptionId "id";

to enter

0
source

All Articles