<?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: How to authenticate databricks provider in terraform using a system-managed identity? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/60081#M31587</link>
    <description>&lt;P&gt;I furthermore also tried to authenticate using a user-assigned managed identity. In detail, I performed the following steps using Terraform:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a user-assigned managed identity in the same resource group as the databricks workspace&lt;/LI&gt;&lt;LI&gt;Create a databricks service principal setting 'application_id' to the client id of the managed identity.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Assign the managed identity the "Contributor" role on the subscription in which the databricks workspace is located.&lt;/LI&gt;&lt;LI&gt;Declare a databricks provider setting 'azure_use_msi&lt;SPAN&gt;' to true, 'host' to the databricks workspace url, 'azure_workspace_resource_id' to the resource id of the databricks workspace, &lt;/SPAN&gt;&lt;SPAN&gt;and&amp;nbsp; 'azure_client_id' to the application id of the managed identity.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Create a databricks token using said provider&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The same error ("Identity not found") occurs during the terraform apply of step 5 (token creation). I also tried creating other resources, they all fail with above-stated error message.&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/333"&gt;@alexott&lt;/a&gt;, do you have a suggestion?&lt;/P&gt;&lt;P&gt;Thanks a lot for your support!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Feb 2024 19:42:48 GMT</pubDate>
    <dc:creator>felix_counter</dc:creator>
    <dc:date>2024-02-13T19:42:48Z</dc:date>
    <item>
      <title>How to authenticate databricks provider in terraform using a system-managed identity?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/59904#M31528</link>
      <description>&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;I want to authenticate the databricks provider using a &lt;STRONG&gt;system-managed identity&lt;/STRONG&gt; in Azure. The identity resides in a different subscription than the databricks workspace:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="managed identity.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/6196i77AB8DD6D53FE79F/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="managed identity.png" alt="managed identity.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;According to the &lt;/SPAN&gt;&lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs#authenticating-with-azure-msi" target="_self"&gt;"authentication" section of the databricks provider documentation&lt;/A&gt;&lt;SPAN&gt;, I performed the following steps:&lt;/SPAN&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;OL&gt;&lt;LI&gt;Grant the (system-assigned) managed identity the "Contributor" role on Subscription B. I can confirm via Azure portal that the app service behind the managed identity indeed has the "Contributor" role on the subscription in which the databricks workspace resides.&lt;/LI&gt;&lt;LI&gt;Register the managed identity as a &lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/service_principal" target="_self"&gt;databricks service principal&lt;/A&gt; in the databricks workspace using its &lt;STRONG&gt;application id&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;Initialize the &lt;STRONG&gt;databricks provider&lt;/STRONG&gt; with the following arguments:&lt;UL&gt;&lt;LI&gt;&lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs#host" target="_self"&gt;host&lt;/A&gt;&lt;SPAN&gt;: host address of the databricks workspace&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs#azure_workspace_resource_id" target="_self"&gt;azure_workspace_resource_id&lt;/A&gt;&lt;SPAN&gt;: resource ID of azure workspace, obtained from an "azurerm_databricks_workspace" data object&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs#azure_client_id" target="_self"&gt;azure_client_id&lt;/A&gt;&lt;SPAN&gt;: &lt;STRONG&gt;application id&lt;/STRONG&gt; of system-managed identity / registered databricks service principal.&amp;nbsp;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;azure_use_msi: true&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;DIV&gt;I tried to create a resource using this provider.&lt;/DIV&gt;&lt;DIV&gt;The terraform plan step looks good, i.e. the resource I want to create shows up in the planning step. However, during the apply step I encounter the following error:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;STRONG&gt;Error: cannot create [redacted]: inner token: token error: ***"error":"invalid_request","error_description":"Identity not found"***&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This error appears independent of the created resource (I tried several ones). The problems seems to be in the authentication with the managed identity.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Is it possible to authenticate the databricks provider using a system-managed identity? If yes, what would be the correct configuration for the provider and the environment in this setup? I am a bit confused on how to point the provider at the right identity to use. In order to point the provider to the correct identity / SPN, I set the parameter "azure_client_id" to the managed identity's application id. However, I am not sure whether this is correct.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 12 Feb 2024 08:56:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/59904#M31528</guid>
      <dc:creator>felix_counter</dc:creator>
      <dc:date>2024-02-12T08:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to authenticate databricks provider in terraform using a system-managed identity?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/59911#M31534</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;thanks a lot for your response describing the &lt;A href="https://learn.microsoft.com/en-us/azure/databricks/dev-tools/azure-mi-auth" target="_self"&gt;step-by-step guide to authenticate Databricks using a managed identity&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;However, to my best understanding this is &lt;U&gt;not&lt;/U&gt; what I want to achieve. To recap, my goal is to use a system-assigned (i.e., not a user-assigned) managed identity of a web app to authenticate with the terraform &lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs" target="_self"&gt;databricks provider&lt;/A&gt;&amp;nbsp;(i.e., not the CLI). I would be very grateful if you could provide a similar step-by-step guide for this setup.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 10:55:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/59911#M31534</guid>
      <dc:creator>felix_counter</dc:creator>
      <dc:date>2024-02-12T10:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to authenticate databricks provider in terraform using a system-managed identity?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/60081#M31587</link>
      <description>&lt;P&gt;I furthermore also tried to authenticate using a user-assigned managed identity. In detail, I performed the following steps using Terraform:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a user-assigned managed identity in the same resource group as the databricks workspace&lt;/LI&gt;&lt;LI&gt;Create a databricks service principal setting 'application_id' to the client id of the managed identity.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Assign the managed identity the "Contributor" role on the subscription in which the databricks workspace is located.&lt;/LI&gt;&lt;LI&gt;Declare a databricks provider setting 'azure_use_msi&lt;SPAN&gt;' to true, 'host' to the databricks workspace url, 'azure_workspace_resource_id' to the resource id of the databricks workspace, &lt;/SPAN&gt;&lt;SPAN&gt;and&amp;nbsp; 'azure_client_id' to the application id of the managed identity.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Create a databricks token using said provider&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The same error ("Identity not found") occurs during the terraform apply of step 5 (token creation). I also tried creating other resources, they all fail with above-stated error message.&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/333"&gt;@alexott&lt;/a&gt;, do you have a suggestion?&lt;/P&gt;&lt;P&gt;Thanks a lot for your support!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2024 19:42:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/60081#M31587</guid>
      <dc:creator>felix_counter</dc:creator>
      <dc:date>2024-02-13T19:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to authenticate databricks provider in terraform using a system-managed identity?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/64387#M32556</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/85492"&gt;@felix_counter&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I have your answer.&lt;/P&gt;&lt;P&gt;To create a databricks provider to manage your workspace using an SPN, you need to create the provider like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;provider "databricks" {
  alias      = "workspace"
  host       = &amp;lt;your workspace URL&amp;gt;
  azure_client_id = &amp;lt;Application ID of the SPN&amp;gt;
  azure_client_secret = &amp;lt;Application secret of the SPN&amp;gt;
  azure_tenant_id = &amp;lt;Your Azure subscription tenant ID&amp;gt;
}&lt;/LI-CODE&gt;&lt;P&gt;I store all these credentials as secrets in my Azure KeyVault and call the keyvault to have access to all its secrets. Then I define data fields to retrieve the secret values from my KeyVault and pass them in the databricks provider definition. You probably know you need to use azurerm provider for this. Below is the full block:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data "azurerm_key_vault" "key_vault" {
  name                = &amp;lt;your keyvault_name&amp;gt;
  resource_group_name = &amp;lt;your rg_name&amp;gt;
}

data "azurerm_key_vault_secret" "workspace_url" {
  name                = "&amp;lt;Workspace-URL&amp;gt;"
  key_vault_id = data.azurerm_key_vault.key_vault.id
}

data "azurerm_key_vault_secret" "workspace_admin_spn_app_id" {
  name                = "&amp;lt;Workspace-ADMINSPN-APPLICATIONID&amp;gt;"
  key_vault_id = data.azurerm_key_vault.key_vault.id
}

data "azurerm_key_vault_secret" "workspace_admin_spn_app_secret" {
  name                = "&amp;lt;Workspace-ADMINSPN-APPLICATIONSECRET&amp;gt;"
  key_vault_id = data.azurerm_key_vault.key_vault.id
}

data "azurerm_key_vault_secret" "tenant_id" {
  name                = "&amp;lt;AZURE-TENANTID&amp;gt;"
  key_vault_id = data.azurerm_key_vault.key_vault.id
}

provider "databricks" {
  alias      = "workspace"
  host       = data.azurerm_key_vault_secret.workspace_url.value
  azure_client_id = data.azurerm_key_vault_secret.workspace_admin_spn_app_id.value
  azure_client_secret = data.azurerm_key_vault_secret.workspace_admin_spn_app_secret.value
  azure_tenant_id = data.azurerm_key_vault_secret.tenant_id.value
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 10:17:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/64387#M32556</guid>
      <dc:creator>FarBo</dc:creator>
      <dc:date>2024-03-22T10:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to authenticate databricks provider in terraform using a system-managed identity?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/112410#M44202</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;There is a solution for this issue?, I'm facing similar issue on Azure devops with managed identity too.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class=""&gt;│&lt;/SPAN&gt; &lt;SPAN class=""&gt;Error: &lt;/SPAN&gt;&lt;SPAN class=""&gt;cannot read spark version: cannot read data spark version: failed during request visitor: inner token: token request: {"error":"invalid_request","error_description":"Identity not found"}&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Luis&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 18:23:49 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/112410#M44202</guid>
      <dc:creator>LuisArs</dc:creator>
      <dc:date>2025-03-12T18:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to authenticate databricks provider in terraform using a system-managed identity?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/112475#M44222</link>
      <description>&lt;P&gt;This answer is for authenticating with a service principal, not a managed identity ("secret-less").&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm also running into the same error and attempted several permutations of the configuration, including attempting to use a databricks_service_principal_password as a secret. All result in different errors.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;data "azurerm_databricks_workspace" "this" {
  name                = var.databricks_workspace_name
  resource_group_name = var.resource_group_name
}

provider "databricks" {
  alias = "spn"

  host                        = data.azurerm_databricks_workspace.this.workspace_url
  azure_workspace_resource_id = data.azurerm_databricks_workspace.this.id
  azure_client_id             = data.azuread_service_principal.access_connector.client_id
  azure_use_msi               = true
}

resource "databricks_token" "access_connector" {
  provider = databricks.spn

  comment = "${data.azuread_service_principal.access_connector.display_name} PAT"
}&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;Neither &lt;A href="https://learn.microsoft.com/en-us/azure/databricks/dev-tools/auth/azure-mi#terraform" target="_self"&gt;Azure documentation&lt;/A&gt; nor &lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs#authenticating-with-azure-msi" target="_self"&gt;Databrick's Terraform provider documentation&lt;/A&gt; approach worked.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 13 Mar 2025 13:58:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/112475#M44222</guid>
      <dc:creator>eparisca</dc:creator>
      <dc:date>2025-03-13T13:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to authenticate databricks provider in terraform using a system-managed identity?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/112481#M44224</link>
      <description>&lt;P&gt;Additionally, the error seems to be intermittent. It affects us greatly because we are using terraform in ci/cd. When it fails, we must re-run it manually. Upon re-running it works, sometimes.&lt;BR /&gt;&lt;BR /&gt;When running it locally, it fails on the first attempt, the succeeds on the second.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 14:35:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/112481#M44224</guid>
      <dc:creator>eparisca</dc:creator>
      <dc:date>2025-03-13T14:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to authenticate databricks provider in terraform using a system-managed identity?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/115321#M45069</link>
      <description>&lt;P&gt;Add an environment variable to you run environment. Add&amp;nbsp;&lt;SPAN&gt;TF_LOG and set it to true. Scroll through and look for an oauth api call. Look at the resource&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have run into the same problem, and it looks our appreg for&amp;nbsp; AzureDatabricks enterprise application is in a different tenant from the rest of our environment.&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;[DEBUG] provider.terraform-provider-databricks_v1.72.0: GET /metadata/identity/oauth2/token?api-version=2018-02-01&amp;amp;client_id=&amp;lt;*****************&amp;gt;&amp;amp;resource=&amp;lt;*********************&amp;gt;&lt;/P&gt;&lt;P&gt;That's when searched for&amp;nbsp;resource=&amp;lt;*********************&amp;gt; in EntraID, and found the app reg missing.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Apr 2025 15:01:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-authenticate-databricks-provider-in-terraform-using-a/m-p/115321#M45069</guid>
      <dc:creator>goTEEMgo</dc:creator>
      <dc:date>2025-04-12T15:01:08Z</dc:date>
    </item>
  </channel>
</rss>

