Cant Log into Azure CLI or powershell I get the following error

Omar Fahnbulleh 1 Reputation point
2022-03-12T16:35:01.59+00:00

PS C:\Windows\System32> Connect-AzAccount
WARNING: Unable to acquire token for tenant '39ae27f6-a789-4d33-b456-a13ec87899dc' with error 'SharedTokenCacheCredential authentication unavailable. No account matching the specified username: jjuste@afyatechnologies.co.ke tenantId: 39ae27f6-a789-4d33-b456-a13ec87899dc was found in the cache.'
WARNING: Unable to acquire token for tenant 'organizations' with error 'SharedTokenCacheCredential authentication unavailable. No account matching the specified username: jjuste@afyatechnologies.co.ke was found in the cache.'
WARNING: Please run 'Connect-AzAccount -DeviceCode' if browser is not supported in this session.
Connect-AzAccount: SharedTokenCacheCredential authentication unavailable. No account matching the specified username: jjuste@afyatechnologies.co.ke was found in the cache.

182399-image.png

Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
652 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Andreas Baumgarten 98,531 Reputation points MVP
    2022-03-12T21:04:36.833+00:00

    Hi @Omar Fahnbulleh ,

    first of all there are two different PowerShell modules available for Azure:

    1. AZRM -> The older one
    2. AZ -> newer one

    Both modules are not compatible which the other, which means you should only use one -> I recommend the AZ module.

    182436-image.png
    Source: https://learn.microsoft.com/de-de/powershell/azure/migrate-from-azurerm-to-az?view=azps-7.3.0

    Installation of the AZ module: https://learn.microsoft.com/de-de/powershell/azure/new-azureps-module-az?view=azps-7.3.0
    Uninstall AZRM module: https://learn.microsoft.com/en-us/powershell/module/az.accounts/uninstall-azurerm?view=azps-7.3.0

    How to know if a command is part of which module:
    If there is a RM in the name of the cmdlet it's from the AZRM module -> e.g. Connect-AzureRmAccount
    https://learn.microsoft.com/en-us/powershell/module/azurerm.profile/connect-azurermaccount?view=azurermps-6.13.0
    The corresponding cmdlet in the AZ module is Connect-AzAccount
    https://learn.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount?view=azps-7.3.0

    Migrating scripts from AZRM to AZ cmdlet is easy in most cases. Just remove the RM in the cmdlet name.

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    1 person found this answer helpful.

  2. risolis 8,701 Reputation points
    2022-03-12T18:56:09.693+00:00

    Hi @Omar Fahnbulleh

    I did not see you running " Install-module xxxx"

    0 comments No comments

  3. Omar Fahnbulleh 1 Reputation point
    2022-03-12T19:30:43.63+00:00

    @risolis

    PS C:\Windows\System32> Import-Module -Name AzureRM.Profile
    Import-Module: The specified module 'AzureRM.Profile' was not loaded because no valid module file was found in any module directory.
    PS C:\Windows\System32> Install-Module -name AzureRM.Profile -Force
    Install-Package: The following commands are already available on this system:'Login-AzAccount,Logout-AzAccount,Resolve-Error,Send-Feedback'. This module 'AzureRM.Profile' may override the existing commands. If you still want to
    install this module 'AzureRM.Profile', use -AllowClobber parameter.

    PS C:\Windows\System32> Install-Module -name AzureRM.Profile -Force
    Install-Package: The following commands are already available on this system:'Login-AzAccount,Logout-AzAccount,Resolve-Error,Send-Feedback'. This module 'AzureRM.Profile' may override the existing commands. If you still want to
    install this module 'AzureRM.Profile', use -AllowClobber parameter.


  4. risolis 8,701 Reputation points
    2022-03-12T20:47:03.253+00:00

    @Omar Fahnbulleh

    Any other concern that I might address ?

    0 comments No comments