Azure Cmdlets - Session Invalid When Using Two-Factor Authentication

I manage many Azure signatures and pretty often use Get-AzureSubscription to list the subscriptions I have access to.

I recently added two-factor authentication to my account. And now I get a strange error for some teams. I can log in using Add-AzureAccount, but when I then try to subscribe to the toi list, I get the error message "Get-AzureSubscription: AADSTS16000: Session is invalid due to expiration or recent password change .

Has anyone else seen this? I would appreciate any ideas on how to get around this.

That's what I'm doing:

 PS C:\ > add-azureaccount Id Type Subscriptions Tenants -- ---- ------------- ------- username@domain.com User xxxxxx-yyyyyy xxxxxx-yyyyyy xxxxxx-yyyyyy xxxxxx-yyyyyy xxxxxx-yyyyyy xxxxxx-yyyyyy xxxxxx-yyyyyy xxxxxx-yyyyyy PS C:\ > Set-AzureSubscription -SubscriptionId 'xxxxxx-yyyyyy' PS C:\ > select-AzureSubscription -SubscriptionId 'xxxxxx-yyyyyy' PS C:\ > Get-AzureSubscription -ExtendedDetails Get-AzureSubscription : AADSTS16000: Session is invalid due to expiration or recent password change. Trace ID: 6fcfa2da-7d7a-43ba-8230-a227312b535b Correlation ID: 7206fefd-29fa-4103-ba4f-eb15350a0754 Timestamp: 2015-04-01 17:57:28Z At line:1 char:1 + Get-AzureSubscription -ExtendedDetails + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-AzureSubscription], AadAuthenticationFailedException + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.GetAzureSubscriptionCommand 
+6
source share
1 answer

I have the same problem, and to start using solvents with Azure PublishFileSettings to manage my 32 certificate subscriptions.

There are steps to add an Azure subscription from PowerShell:

  • Open the browser https://manage.windowsazure.com and add your credentials as Service-Admin or Co-Admin

  • Use PowerShell and load publication options using this cmdlet:

      Get-AzurePublishSettingsFile 
  • At this point, the browser redirects the file download; you need to save it.

  • They need to import this certificate file using:

      Import-AzurePublishSettingsFile -PublishSettingsFile "C: \ Azure \ PublishSettingsFile \ MySubscripcion-credentials.publishsettings" 
  • You are now ready to list your Azure subscription without a password or expired credentials, which may differ from using Add-AzureAccount.

      Get-AzureSubscription |  ft SubscriptionName, CurrentStorageAccountName, SubscriptionId -AutoSize 
  • Finally, you can now select the subscription you want to manage.

      Select-AzureSubscription -SubscriptionName "MySubscripcion" 

I hope this procedure helps you.

Hello

0
source

Source: https://habr.com/ru/post/984603/


All Articles