Terraform apply results in Error populating Client ID from the Azure CLI

Solution 1:

Error: Error building AzureRM Client: Error populating Client ID from the Azure CLI: No Authorization Tokens were found - please ensure the Azure CLI is installed and then log-in with az login.

This error is due to the Azure CLI version that you are using . There was a breaking change in the Azure CLI version 2.30.0 where Azure migrated the authentication from ADAL to MSAL. For which if you are using Azure CLI latest and Terraform azurerm old then , it will fail in authentication which will result in the error.

To Fix the problem you will have to use the latest Azure CLI version i.e. 2.32.0 and also at the same time try to use the terraform latest azurerm Provider i.e. 2.92.0.

To Upgrade CLI version , You can run az upgrade command and in terraform you can use the below :

terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "2.92.0"
    }
  }
}

provider "azurerm" {
  # Configuration options
}

You can refer these Similar Github Issues are well : Issue 1 and Issue 2