Rafael Colucci
Rafael Colucci

Reputation: 6078

How to create an Azure Data factory Azure SQL Database dataset using terraform

I am trying to create an Azure SQL Database dataset using terraform for my Azure Data Factory. The code bellow works fine to define a linked service:

resource "azurerm_data_factory_linked_service_azure_sql_database" "example" {
  name                = "example"
  resource_group_name = azurerm_resource_group.example.name
  data_factory_name   = azurerm_data_factory.example.name
  connection_string   = "data source=serverhostname;initial catalog=master;user id=testUser;Password=test;integrated security=False;encrypt=True;connection timeout=30"
}

But I can't find a way to create the dataset, since the only resource provider for SQL datasets is the azurerm_data_factory_dataset_sql_server which does not work with the provider azurerm_data_factory_linked_service_azure_sql_database because it was supposed to be used with the azurerm_data_factory_linked_service_sql_server

Upvotes: 1

Views: 1418

Answers (2)

vdm2010
vdm2010

Reputation: 21

It's been a while, but maybe someone could use the solution. You could use: azurerm_data_factory_custom_dataset

resource "azurerm_data_factory_custom_dataset" "DatasetSource" {
  name            = "Your ADF Name"
  data_factory_id = "Your ADF id"
  type            = "AzureSqlTable"

  linked_service {
    name = azurerm_data_factory_linked_service_azure_sql_database.LinkedServicesDBSource.name
  }

  type_properties_json = <<JSON
{
}
JSON

}

Upvotes: 2

Jason Welch
Jason Welch

Reputation: 986

It looks like this isn't supported in tf yet (as I'm discovering are a lot of things).

You could raise it here https://github.com/terraform-providers/terraform-provider-azurerm as an enhancement - there are a couple of kind folk actively adding tf resources in this area.

We made a decision to implement our linked services in tf (because they contain/use secrets we can inject in the pipeline), but are deploying datasets as JSON from the repo. Any reason why you want to deploy them with tf specifically? Did we miss something?

Upvotes: 0

Related Questions