After succesful connection with Connect-AzAccount subsequent command fails with SharedTokenCacheCredential authentication unavailable

Servaas Phlips 0 Reputation points
2025-02-27T09:05:26.1566667+00:00

I am trying to use Microsoft sandbox to learn how to work with AZ Powershell. However every single time I try to use it I bump into issues.

I have 3 different accounts. One for the consultancy company I work for, One for the company I do my consulting and one is my own private. I am trying to use my own private account for the sandbox.

Because I have 3 different accounts I try to be as explicit as possible when I connect:

I explicitly set the tenant id and subscription id to avoid confusion:


Connect-AzAccount -TenantId TENANT_OF_MS_LEARN -Subscription GENERATED_SUBSCRIPTION_ID_FOR_MS_LEARN

It asks me to choose an account and I choose the private own:

First account selection

When I have choosen an account, I need to AGAIN pick an account in a dialog. In this dialog every single time the private account is not displayed, so I need to manually enter it EVERY SINGLE TIME Why isn't the private account in this list ?

User's image

Pick account (private account missing)

When I have done that and I approve the request in microsoft Authenticator. I am greeted with the following output of the command Connect-AzAccount -TenantId TENANT_OF_MS_LEARN -Subscription GENERATED_SUBSCRIPTION_ID_FOR_MS_LEARN:


Please select the account you want to login with.

Retrieving subscriptions for the selection...

Subscription name      Tenant

-----------------      ------

Concierge Subscription TENANT_OF_MS_LEARN

However as soon as I do any subsequent actions I get the following messages:

When I do Get-AzSubscription:


WARNING: Unable to acquire token for tenant 'TENANT_OF_MS_LEARN' with error 'SharedTokenCacheCredential authentication unavailable. No account matching the specified username: ******@hotmail.com tenantId: TENANT_OF_MS_LEARN was found in the cache.'

WARNING: Unable to acquire token for tenant 'TENANT_OF_MS_LEARN' with error 'SharedTokenCacheCredential authentication unavailable. No account matching the specified username: ******@hotmail.com tenantId: TENANT_OF_MS_LEARN was found in the cache.'

When I do Set-AzDefault -ResourceGroupName learn-RESOURCE_GROUP_CREATED_BY_MS_LEARN (name of created sandbox):


Set-AzDefault: Your Azure credentials have not been set up or have expired, please run Connect-AzAccount to set up your Azure credentials.

SharedTokenCacheCredential authentication unavailable. No account matching the specified username: ******@hotmail.com tenantId: TENANT_OF_MS_LEARN was found in the cache.

Why am I getting all this weird errors ?

What have I done so far:

  • Performed Uninstall-AzureRm (as administrator)
  • Installed Install-Module Az
  • restarted computer
  • performed "Clear-AzContext"

Some additional info when I first created a sandbox environment the MS website asked me to create an account for MS authenticator (although I already had one), since I couldn't continue I complied and scanned the QR code, the result is now that I have many account in Microsoft Authenticator:

  • one for the consultancy company I work
  • one for the company I do my consulting
  • one for my private account looking like ******@hotmail.com
  • one for my private account looking like MY_USERNAME_hotmail.com#EXT#@SOME_SUB_DOMAIN.onmicrosoft.com
Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
2,143 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.