hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

azurerm_data_factory_dataset_azure_sql_table - Table not set #25957

Open Paxilein opened 6 months ago

Paxilein commented 6 months ago

Is there an existing issue for this?

Community Note

Terraform Version

1.8.1

AzureRM Provider Version

3.103.1

Affected Resource(s)/Data Source(s)

azurerm_data_factory_dataset_azure_sql_table

Terraform Configuration Files

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_data_factory" "example" {
  name                = "example"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_data_factory_linked_service_azure_sql_database" "example" {
  name              = "example"
  data_factory_id   = azurerm_data_factory.example.id
  connection_string = "Integrated Security=False;Data Source=test;Initial Catalog=test;Initial Catalog=test;User ID=test;Password=test"
}

resource "azurerm_data_factory_dataset_azure_sql_table" "example" {
  name              = "example"
  data_factory_id   = azurerm_data_factory.example.id
  linked_service_id = azurerm_data_factory_linked_service_azure_sql_database.example.id
  schema = "dbo"
  table_name = "foo"
}

Debug Output/Panic Output

N/A

Expected Behaviour

The dataset should have the table "foo" configured in ADF, like it does when using the azurerm_data_factory_dataset_sql_server_table

Actual Behaviour

The table field in ADF Studio shows "Select..." and the "Enter manually" is disabled. We have to manually select a table before it works... Maybe the manual field isn't configured to be set in this resource when the table is specified?

Steps to Reproduce

No response

Important Factoids

No response

References

No response

Paxilein commented 6 months ago

There's also an inconsistency as the azurerm_data_factory_dataset_sql_server_table uses "table_name" and does not have "schema" while azurerm_data_factory_dataset_azure_sql_table uses "table" and "schema"!?

Paxilein commented 6 months ago

Another interesting thing I found... After the deployment the typeproperties "schema" and "table" are set like I configured in Terraform... However, when I choose the table from the dropdown it removes both of those typeproperties and puts a new typeproperty "tablename" there...

After deployment: "typeProperties": { "schema": "dbo", "table": "foo" }

After selecting the table from the dropdown: "typeProperties": { "tableName": "[dbo].[foo]" }

I don't do GoLang but I think maybe the azurerm_data_factory_dataset_azure_sql_table just sets the wrong thing (table and schema) and should configure tablename instead, like the azurerm_data_factory_dataset_sql_server_table does?

JustinSometimesWrong commented 4 months ago

This is still an issue.

damews commented 1 month ago

@Paxilein I had this same issue when trying to use the azurerm_data_factory_dataset_azure_sql_table resource. After searching the "Azure Dataset Bicep" into Google, i landed on this doc: https://learn.microsoft.com/en-us/azure/templates/microsoft.datafactory/factories/datasets?pivots=deployment-language-terraform

After applying the resource using the azapi_resource as mentioned in the doc, the issue still occurred. One thing I noticed is that when the Dataset is created manually, the column schema is loaded automatically, and the JSON representation of the Dataset shows the column schema.

I added the column schema, applied it again, and this time it worked as expected. See if adding the column schema resolves the issue for you.

Obs: the azurerm_data_factory_dataset_azure_sql_table has the schema_columns block