Solving the error “Could not retrieve credential from local cache” in the Azure CLI

Today I encountered this annoying error message in the Azure CLI. I Googled but found a lot of things that are not quite right. So… For now, my own solution to the issue. The error in the Azure CLI states this:

> “Could not retrieve credential from local cache for service principal 00000-00000-00000-00000 under tenant 00000-00000-00000-00000. Trying credential under tenant 00000-00000-00000-00000, assuming that is an app credential.”

What it is? Basically, the Azure CLI fails to retrieve credentials from the local cache for a specific service principal.

When you see this error, it means that the Azure CLI is unable to authenticate your request using the cached credentials for the service principal associated with the provided GUIDs. To overcome this issue and clear the credentials, you can use a simple command: az account clear.

Running the az account clear command clears the cached credentials in the Azure CLI and allows you to start fresh with new credentials. After running this command, you can reauthenticate and obtain new credentials using the appropriate authentication method, such as interactive login or a service principal.

Comments are closed.