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

For some reason I run into an issue today when I was creating this blogpost where after signing in with PowerShell to Azure with Connect-AzAccount I was unable to run any other commands. I have tried all different kind of possible solution, from clearing cache, temp folders, reboot, installing updates etc. but none of these was the solution to this.
After a while of troubleshooting I remembered that with AzureRm I did have this issue aswell. Clearing the Azure Profile was the solution for this. For Az there is still such a command, ‘Clear-AzContext’.

Issue

PS C:\Users\HeyAzureGuy> Connect-AzAccount -Tenant '***'

Account; SubscriptionName; TenantId; Environment
daniel.etten@heyazureguy.com; HeyAzureGuy; ***; AzureCloud 

PS C:\Users\HeyAzureGuy> Get-AZRoleAssignment
Get-AZRoleAssignment : Your Azure credentials have not been set up or have expired, please run Connect-AzAccount to set up your Azure credentials.
At line:1 char:1
+ Get-AZRoleAssignment
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzRoleAssignment], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.GetAzureRoleAssignmentCommand

Solution

Run the Clear-AzContext Commandlet and then try Connect-AzAccount to get the valid bearer token to continue.

PS C:\Users\HeyAzureGuy> Clear-AzContext -Force

Have a cloudy day!

About Daniel Etten

My name is Daniƫl Etten. I work as a Premier Field Engineer (PFE) at Microsoft. Together with Paul, a former colleague of mine at KPN, I started this blog to share our experiences with Azure to other Azure minded people and as a personal repo of Azure info. Opinions are my own.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

2 thoughts on “Your Azure credentials have not been set up or have expired, please run Connect-AzAccount to set up your Azure credentials

  1. IT Tech

    did not work, sorry
    My azure, does connect, while i am building vms, it sometimes creates some vms and doesnt create other with no output/warning or error.

    Third attempt it creates all.

    very weird issue.

    Regards
    IT tech

    Reply
    1. Daniel Etten Post author

      Sorry to hear that the solution didn’t worked out for you!
      Have you checked in the Azure portal if there where any issues listed there in the Resource Group Deployment?

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *