I struggled today with issues related to the PowerShell connection to Azure.
If I use the command Connect-AzAccount I was connected successfully but I received a Warning: ‚Unable to acquire token for tenant‘.
I wanted to use another command: Get-AzVM but I received an error:
Get-AzVM: Your Azure credentials have not been set up or have expired, please run Connect-AzAccount to set up your Azure credentials.
I started to seek how to fix it. Some guys recommended using the Clear-AzContex command but it doesn’t help me.
I was wondered what happens when I will be more strict in my connection definition so I tried another command out with more switches:
Connect-AzAccount -TenantId ‚xxx‘ -SubscriptionId ‚xxx‘.
You can use the command for TenadId and SubscriptionID or check values directly in Azure Portal.
Get-AzContext | Select-Object *