How to authenticate from Terraform Cloud to Azure?


I’m new to Terraform. Using Terraform Cloud I try to create a resource group in Azure. I have a very simple file in github containing this:

provider “azurerm” {
subscription_id = “ID-removed”
tenant_id = “Tenant-ID-removed”

resource “azurerm_resource_group” “temp01” {
name = “someNameNotFoundAlready”
location = “East US”

In Terraform Cloud I defined environment variabels for

In Azure I’ve setup RBAC on the subscription using:
PS Azure:> az ad sp create-for-rbac --role=“Contributor” --scopes="/subscriptions/Subscription-ID-removed"

The generated appId is then configured in Terraform Cloud as client_id and password as client_secret.

When I queue the plan in Terraform Cloud it fails with this message:
Error: 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.

on line 1, in provider “azurerm”:
1: provider “azurerm” {

Isn’t it possible to authenticate to Azure this way from Terraform Cloud? It seems like the Azure CLI is not available. I can connect from Azure cloud console locally, but that is not what I want. I’ve read the relevant documentation multiple times, but it seems like it mostly addresses the local scenario.

Thanks in advance!

1 Like

I believe you can set the client id and client secret using environment variables in Terraform cloud. I stand to be corrected but I believe the following variables will work.


as long as you set these as environment variables in the workspace, you should be good to go. Happy Terraforming :blush:

Thanks a lot!

I got it working now…:slight_smile:

Localhost I used quotes around the keys (when passing them in as environment variables). In Terraform Cloud I also had quotes in around the variables. When I removed the quotes around the various keys in TFC it worked fine.

1 Like