Skip to content

backend/azure doesn't find access tokens from az cli when AZURE_CONFIG_DIR is set #25416

@gjtaylor

Description

@gjtaylor

Terraform Version

$ terraform version
Terraform v0.12.28
...

Terraform Configuration Files

terraform {
  backend "azurerm" {
    resource_group_name  = "StorageAccount-ResourceGroup"
    storage_account_name = "abcd1234"
    container_name       = "tfstate"
    key                  = "prod.terraform.tfstate"
  }
}

(the resources don't actually need to exist to demonstrate this issue)

Debug Output

https://gist.github.com/gjtaylor/3aa7bad9b7b2961e98214d1bcfd681eb

Crash Output

Expected Behavior

terraform should have used the access token from the az login to authenticate to the remote backend.

Actual Behavior

Error: Error building ARM Config: 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'.

Steps to Reproduce

$ export AZURE_CONFIG_DIR=[not $HOME/.azure]
$ az login
You have logged in. Now let us find all the subscriptions to which you have access...
...
$ terraform init

Additional Context

References

Similar problem in hashicorp/terraform-provider-azurerm#5891

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions