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!
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
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?
Try Installing latest version Az.Accounts 1.9.0 or more latest