0

I am using powershell to connect to azure interactively, where i will give my username and password and script will fetch the secrets from the key vault . I am not suppose to use the app id here . I was using azure module and powershell 5.1 where the Connect-AzAccount command used to work , open a browser and let me feed my details .

From last 3 days , i am seeing the below error . It is not showing up any browser window

WARNING: Unable to acquire token for tenant 'organizations' with error 'InteractiveBrowserCredential authentication failed: Retry failed after 4 tries.'

I have tried to delete the azure context files and try again but facing the same issue

Rajesh
  • 41
  • 2
  • 6
  • 1
    Some report that using `Clear-AzContext -Force` before `Connect-AzAccount` could fix this. – Theo Oct 09 '21 at 11:39

1 Answers1

0

You may try the suggestion in comment. If not,it may occur due to different reasons,some times it may also be due to network issue and delay.

Some work arounds that you may try.

  1. Please clear the cache and try running the following command in order : Install-Module Az Import-Module Az Connect-AzAccount with” Windows PowerShell ISE".
  2. As you were saying it worked previously, It may have had upgraded to newer version say 2.2.8.Try down grading the Az.Accounts package to version example:1.6.Or you may try the other way around by upgrading. PowerShell developer reference for Azure Functions | Microsoft Docs
  3. Try to install AZ module on your PowerShell and set your execution policy to remote signed.
  4. Give your tenant ad directly Connect-AzAccount -TenantId cf2a0-*******
  5. Try "Connect-AzAccount -UseDeviceCode" or "Connect-AzureAd"
  6. Check if Grant API permissions to read or read/write on Azure Active Directory to the application.ex:Directory.ReadWriteAll is done. Make sure Managed Service Identity (MSI) has been turned on, and in Keyvault is granted the MSI access policies.And check if user is assigned role .
  7. Try to run your powershell as admin, update the module with Update-Module -Name Az, then login again.
  8. You may use "Connect-AzAccount -Identity -ErrorAction Stop" To catch the error

If issue is not resolved you may raise a support request.

References:

  1. Troubleshoot Azure Automation runbook issues| Microsoft Docs
  2. Using Azure Key Vault with PowerShell
  3. Other SO reference
kavyaS
  • 8,026
  • 1
  • 7
  • 19