0
votes

I have installed az-cli using azure link and terraform apt-get. Getting below error while

Error: Error running plan: 1 error(s) occurred:

  • provider.azurerm: Error building AzureRM Client: Azure CLI Authorization Profile was not found. Please ensure the Azure CLI is installed and then log-in with az login.

Tried to uninstall and reinstall, but no luck.

3

3 Answers

0
votes

In my case this issue because Terraform was out of date when installed with apt-get. Instead I downloaded latest version from here and then it worked seemlessly.

0
votes

In my case that was because I manually copied Terraform state from local to azurerm backend. When I did it the "terraform way" (change backend, init again, then terraform asks you if you want to copy the old state to the new backend), it started working.

0
votes
1.Generate AZ CLI Service principal using the following doc,
 https://www.terraform.io/docs/providers/azurerm/guides/service_principal_client_secret.html#configuring-the-service-principal-in-terraform

   2.Create main.tf like below;

   <pre>
   variable "client_secret" {
     type = string
   default = "312312321321313131.cNSUbpQ8tmX.0"
   }

   provider "azurerm" {
   version = "=2.5.0"

    subscription_id = "312213-a480-4f81-9c11-698ea4e5bdc1"
    client_id       = "12321321-3a4c-4b8a-b368-360a3b1d10fe"
    client_secret   = var.client_secret
    tenant_id       = "3123213-331a-48ba-b45d-58132312435c"
      features {}
    }
    </pre>

    3.terraform init - plan