Authentication Issue with Azure Cloud Shell

Michael Cameron 612 Reputation points
2024-08-16T09:40:49.15+00:00

When launching a new Azure Cloud Shell session, my credentials are sometimes rejected for certain Az cmdlets but not for others. The command Get-AzContext shows that my account is MSI@50342 as expected. Examples of cmdlets that do not work include Get-AzRoleAssignment and Get-AzADOrganization. Running these commands results in the following error:

ManagedIdentityCredential authentication failed: Service request failed.
Status: 400 (Bad Request)
Content:
{"error":{"code":"invalid_request","message":"Timeout waiting for token from portal. Audience: https://graph.microsoft.com/"}}

Running Disconnect-AzAccount and then reconnecting with Connect-AzAccount -Identity results in the same issue. This issue does not happen consistently but when it does, the cmdlets that work/don't work are the same.
Debug and verbose options offer do not help.

I cleared some cookies from azure.com and that seemed to fix things, but I don't know if that was coincidence. Does anyone have any insight into this? And please note that I am able to use chatgpt and Q&A assist by myself, so there is no need to post that for me.

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} vote

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.