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

I currently 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.

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

Leave a Reply

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