ADF linked service for ADLS - Terraform

Rajat Srivastava 40 Reputation points
2023-10-12T07:36:14.38+00:00

I have been trying to make a linked service for ADLS. I want to access the ADLS using the secrets stored in my Key Vault. I have made a linked service to access Key Vault.

Now I want to access the ADLS using the Key Vault linked service (like we are able to do on the Azure Portal) I need to write terraform script for the same.

I have been trying to find out how to do this, but have not been able to find any solution.

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
{count} votes

1 answer

Sort by: Most helpful
  1. Bhargava-MSFT 31,356 Reputation points Microsoft Employee Moderator
    2023-10-17T21:04:57.28+00:00

    Hello Rajat Srivastava,

    Thanks for the details.

    To create a ADLS gen2 linked service that uses the key valut, then you need to use either service principal or account key authentication.

    here is an example using service principal

    # Define the Key Vault linked service
    resource "azurerm_data_factory_linked_service_key_vault" "key_vault" {
      name                = "key_vault_linked_service"
      data_factory_name   = azurerm_data_factory.data_factory.name
      resource_group_name = azurerm_resource_group.resource_group.name
      vault_uri           = "https://.vault.azure.net/"
      tenant_id           = ""
      client_id           = ""
      client_secret       = ""
    }
    
    # Define the ADLS Gen2 linked service
    resource "azurerm_data_factory_linked_service_data_lake_storage_gen2" "adls_gen2" {
      name                = "adls_gen2_linked_service"
      data_factory_name   = azurerm_data_factory.data_factory.name
      resource_group_name = azurerm_resource_group.resource_group.name
      account_name        = ""
      authentication_type = "ServicePrincipal"
      service_principal_id = azurerm_data_factory_linked_service_key_vault.key_vault.get_secret("")
      service_principal_key = azurerm_data_factory_linked_service_key_vault.key_vault.get_secret("")
      tenant_id           = ""
    }
    

    https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_factory_linked_service_key_vault

    https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_factory_linked_service_data_lake_storage_gen2

    Sorry, I don't have an environment to test the script and I have used AI to generate the script.

    I hope this helps.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.