<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cannot use Terraform to create Databricks Storage Credential in Administration &amp; Architecture</title>
    <link>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/111302#M3061</link>
    <description>&lt;P&gt;I used the following configure in `main.tf`.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;provider "databricks" {
  auth_type = "pat"
}&lt;/LI-CODE&gt;&lt;P&gt;Then, in my Azure Pipeline, I configure the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;......
    - task: AzureCLI@2
      displayName: 'Get Databricks access token'
      inputs:
        azureSubscription: $(DEVOPS_SERVEICE_CONNECTION)
        scriptType: 'bash'
        scriptLocation: 'inlineScript'
        inlineScript: |
          echo "Getting access token..."
          DATABRICKS_TOKEN=$(az account get-access-token --resource 2ff814a6-3304-4ab8-85cb-cd0e6f879c1d --query "accessToken" -o tsv)
          echo "##vso[task.setvariable variable=DATABRICKS_TOKEN]$DATABRICKS_TOKEN"
......
    - task: TerraformTaskV4@4
      name: terraformPlan
      displayName: Create Terraform Plan
      inputs:
        provider: 'azurerm'
        command: 'plan'
        commandOptions: '-out main.tfplan'
        environmentServiceNameAzureRM: '$(DEVOPS_SERVEICE_CONNECTION)'
......&lt;/LI-CODE&gt;&lt;P&gt;I hope this is helpful.&lt;/P&gt;</description>
    <pubDate>Wed, 26 Feb 2025 19:35:40 GMT</pubDate>
    <dc:creator>AlbertWang</dc:creator>
    <dc:date>2025-02-26T19:35:40Z</dc:date>
    <item>
      <title>Cannot use Terraform to create Databricks Storage Credential</title>
      <link>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/91354#M1870</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;When I use Terraform in an Azure DevOps pipeline to create Databricks&amp;nbsp;Storage Credential, I got the following error. Has anybody met the same error before? Or is there any idea how to debug it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error: cannot create storage credential: failed during request visitor: default auth: azure-cli: cannot get account info: exit status 1.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My implementation.&lt;/P&gt;&lt;P&gt;(1) Below is my `main.tf`. It works well on my local using my own Azure account.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "4.2.0"
    }
    databricks = {
      source = "databricks/databricks"
      version = "1.52.0"
    }
  }
}

provider "azurerm" {
    features {}
    subscription_id = "${var.AZURE_SUBSCRIPTION_ID}"
}

provider "databricks" {
  host  = var.DATABRICKS_HOST
  retry_timeout_seconds = 600
}

data "azurerm_databricks_access_connector" "unity_catalog_access_connector" {
  name                = "unity-catalog-access-connector"
  resource_group_name = "rg-dbr-managed-${var.ENVIRONMENT}"
}

resource "databricks_storage_credential" "dbr_strg_cred" {
  name = "dbr_strg_cred_${var.ENVIRONMENT}"
  azure_managed_identity {
    access_connector_id = data.azurerm_databricks_access_connector.unity_catalog_access_connector.id
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(2) However, I got an error when I apply the Terraform file in an Azure DevOps pipeline. Below is my `azure-pipelines.yaml`.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;trigger: none

pool:
  vmImage: ubuntu-latest

variables:
  - group: vg-dbr-dev

stages:
- stage: setup

  jobs:
  - job: setup
    displayName: "Set up Databricks workspace using Terraform"
    steps:

    - script: |
        echo "##vso[task.setvariable variable=TF_VAR_DATABRICKS_HOST]$DATABRICKS_HOST"
        echo "##vso[task.setvariable variable=TF_VAR_AZURE_SUBSCRIPTION_ID]$AZURE_SUBSCRIPTION_ID"
        echo "##vso[task.setvariable variable=TF_VAR_ENVIRONMENT]$ENV"
      displayName: 'Set up environment variables'

    - script: env | sort
      displayName: 'Environment / Context'

    - task: UsePythonVersion@0
      displayName: 'Use Python 3.12'
      inputs:
        versionSpec: 3.12

    - script: |
        python -m pip install wheel
      displayName: 'Install dependencies' 

    - task: TerraformInstaller@1
      displayName: Install Terraform 1.9.2
      inputs:
        terraformVersion: 1.9.2

    - task: TerraformTaskV4@4
      displayName: Initialize Terraform
      inputs:
        provider: 'azurerm'
        command: 'init'
        backendServiceArm: '$(DEVOPS_SERVEICE_CONNECTION)'
        backendAzureRmResourceGroupName: '$(TERRAFORM_STATE_STORAGE_RESOURCE_GROUP_NAME)'
        backendAzureRmStorageAccountName: '$(TERRAFORM_STATE_STORAGE_ACCOUNT_NAME)'
        backendAzureRmContainerName: '$(TERRAFORM_STATE_STORAGE_CONTAINER_NAME)'
        backendAzureRmKey: 'state.tfstate'

    - task: TerraformTaskV4@4
      name: terraformPlan
      displayName: Create Terraform Plan
      inputs:
        provider: 'azurerm'
        command: 'plan'
        commandOptions: '-out main.tfplan'
        environmentServiceNameAzureRM: '$(DEVOPS_SERVEICE_CONNECTION)'

    # Only runs if the 'terraformPlan' task has detected changes the in state. 
    - task: TerraformTaskV4@4
      displayName: Apply Terraform Plan
      condition: eq(variables['terraformPlan.changesPresent'], 'true')
      inputs:
        provider: 'azurerm'
        command: 'apply'
        commandOptions: 'main.tfplan'
        environmentServiceNameAzureRM: '$(DEVOPS_SERVEICE_CONNECTION)'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(3) In the Azure DevOps pipeline, I use a DevOps Service Connection, which refers to a Microsoft Entra ID app (a service principal). I have added this service principal to the Databricks account and the Databricks workspace, and give the service principal the account admin and workspace admin permissions.&lt;/P&gt;&lt;P&gt;However, the pipeline reports error in the last step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;/opt/hostedtoolcache/terraform/1.9.2/x64/terraform apply -auto-approve main.tfplan
databricks_storage_credential.dbr_strg_cred: Creating...
╷
│ Error: cannot create storage credential: failed during request visitor: default auth: azure-cli: cannot get account info: exit status 1. Config: host=https://adb-123123123123123.1.azuredatabricks.net, azure_client_id=***, azure_tenant_id=d123123-1234-1234-1234-123123123. Env: DATABRICKS_HOST, ARM_CLIENT_ID, ARM_TENANT_ID
│ 
│   with databricks_storage_credential.dbr_strg_cred,
│   on main.tf line 33, in resource "databricks_storage_credential" "dbr_strg_cred":
│   33: resource "databricks_storage_credential" "dbr_strg_cred" {
│ 
╵

##[error]Error: The process '/opt/hostedtoolcache/terraform/1.9.2/x64/terraform' failed with exit code 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody have any idea? Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2024 02:27:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/91354#M1870</guid>
      <dc:creator>AlbertWang</dc:creator>
      <dc:date>2024-09-23T02:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use Terraform to create Databricks Storage Credential</title>
      <link>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/91497#M1879</link>
      <description>&lt;P&gt;Still struggling with this issue. Can anyone kindly help?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2024 00:26:40 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/91497#M1879</guid>
      <dc:creator>AlbertWang</dc:creator>
      <dc:date>2024-09-24T00:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use Terraform to create Databricks Storage Credential</title>
      <link>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/91625#M1883</link>
      <description>&lt;P&gt;I found the reason. Because I did not configure the `auth_type` for the Terraform Databricks provider, it uses the default auth type `azure-cli`. However, in my pipeline, I did not log in Azure CLI using `az login`. Therefore, the authentication of the Terraform Databricks provider does not work.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2024 20:41:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/91625#M1883</guid>
      <dc:creator>AlbertWang</dc:creator>
      <dc:date>2024-09-24T20:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use Terraform to create Databricks Storage Credential</title>
      <link>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/111248#M3053</link>
      <description>&lt;P&gt;How exactly do you need to configure auth_type in this case? I tried different options but nothing seems to work. I also would like to use the Service Connection from Azure DevOps Pipeline to deploy Databricks via TerraformTaskV4@4.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 10:40:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/111248#M3053</guid>
      <dc:creator>MichaelFu</dc:creator>
      <dc:date>2025-02-26T10:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use Terraform to create Databricks Storage Credential</title>
      <link>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/111302#M3061</link>
      <description>&lt;P&gt;I used the following configure in `main.tf`.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;provider "databricks" {
  auth_type = "pat"
}&lt;/LI-CODE&gt;&lt;P&gt;Then, in my Azure Pipeline, I configure the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;......
    - task: AzureCLI@2
      displayName: 'Get Databricks access token'
      inputs:
        azureSubscription: $(DEVOPS_SERVEICE_CONNECTION)
        scriptType: 'bash'
        scriptLocation: 'inlineScript'
        inlineScript: |
          echo "Getting access token..."
          DATABRICKS_TOKEN=$(az account get-access-token --resource 2ff814a6-3304-4ab8-85cb-cd0e6f879c1d --query "accessToken" -o tsv)
          echo "##vso[task.setvariable variable=DATABRICKS_TOKEN]$DATABRICKS_TOKEN"
......
    - task: TerraformTaskV4@4
      name: terraformPlan
      displayName: Create Terraform Plan
      inputs:
        provider: 'azurerm'
        command: 'plan'
        commandOptions: '-out main.tfplan'
        environmentServiceNameAzureRM: '$(DEVOPS_SERVEICE_CONNECTION)'
......&lt;/LI-CODE&gt;&lt;P&gt;I hope this is helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2025 19:35:40 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/111302#M3061</guid>
      <dc:creator>AlbertWang</dc:creator>
      <dc:date>2025-02-26T19:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use Terraform to create Databricks Storage Credential</title>
      <link>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/111356#M3062</link>
      <description>&lt;P&gt;Thank you for your reply! Where is $DATABRICKS_TOKEN then used in the terraform template?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 06:51:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/111356#M3062</guid>
      <dc:creator>MichaelFu</dc:creator>
      <dc:date>2025-02-27T06:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use Terraform to create Databricks Storage Credential</title>
      <link>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/111409#M3067</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;echo "##vso[task.setvariable variable=DATABRICKS_TOKEN]$DATABRICKS_TOKEN"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The DATABRICKS_TOKEN is set as an environment variable. As mentioned,&amp;nbsp;&lt;A href="https://docs.databricks.com/aws/en/dev-tools/auth/pat" target="_blank"&gt;https://docs.databricks.com/aws/en/dev-tools/auth/pat&lt;/A&gt;&amp;nbsp;and&amp;nbsp;&lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/token" target="_blank" rel="noopener"&gt;databricks_token | Resources | databricks/databricks | Terraform | Terraform Registry&lt;/A&gt;. The&amp;nbsp;DATABRICKS_TOKEN will be used by Terraform for auth because&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;PRE&gt;auth_type = "pat"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2025 20:04:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/111409#M3067</guid>
      <dc:creator>AlbertWang</dc:creator>
      <dc:date>2025-02-27T20:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use Terraform to create Databricks Storage Credential</title>
      <link>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/117996#M3326</link>
      <description>&lt;P&gt;Thank you so much for posting, what is this --resource id?&amp;nbsp; the managed account? the access connector or another app registration?&amp;nbsp; &amp;nbsp;I have tried the resource provider in ADO, it doesnt seem to matter. I can't auth no matter what i try.&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 21:20:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/117996#M3326</guid>
      <dc:creator>PhatAdam</dc:creator>
      <dc:date>2025-05-06T21:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use Terraform to create Databricks Storage Credential</title>
      <link>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/118001#M3329</link>
      <description>&lt;P&gt;You are welcome, PhatAdam.&lt;/P&gt;&lt;P&gt;This ID is the&amp;nbsp;programmatic ID for Azure Databricks, or&amp;nbsp;the unique resource ID for the Azure Databricks service. It is not my company's resource id, but Databricks Service's id. So I did not mask it when posting &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can find more details from this article.&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/dev-tools/auth/service-prin-aad-token" target="_blank"&gt;Get Microsoft Entra ID tokens for service principals - Azure Databricks | Microsoft Learn&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 22:37:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/cannot-use-terraform-to-create-databricks-storage-credential/m-p/118001#M3329</guid>
      <dc:creator>AlbertWang</dc:creator>
      <dc:date>2025-05-06T22:37:26Z</dc:date>
    </item>
  </channel>
</rss>

