I am new to Terraform.
I am looking online for example in Terraform (provider "hashicorp/azurerm") for creating a linked service in Synapse linking to:
Azure datalake storage account
Azure sql server
My code which doesn’t work…
> resource "azurerm_synapse_linked_service"
> "synapse_linked_service_datalake" {
> depends_on = [module.add_synapse_firewall_rule0, azurerm_storage_data_lake_gen2_filesystem.datalake_fs,
> data.azurerm_storage_account.datalake, module.set_role_storage]
> name = "linked-service-to_${data.azurerm_storage_account.datalake.name}"
> synapse_workspace_id = azurerm_synapse_workspace.synapse.id
> type = "AzureBlobFS"
> type_properties_json = <<JSON
> {
> "connectionString": "DefaultEndpointsProtocol=https;AccountName=${data.azurerm_storage_account.datalake.name};AccountKey=${data.azurerm_storage_account.datalake.primary_access_key};EndpointSuffix=core.windows.net"
> }
> JSON }
The error I get….
2023-07-15T12:55:58.2894784Z [31m│[0m [0m "Name": "linked-service-to_XXXXXXXXX", 2023-07-15T12:55:58.2895043Z [31m│[0m [0m "Properties": { 2023-07-15T12:55:58.2895237Z [31m│[0m [0m "type": "AzureBlobFS", 2023-07-15T12:55:58.2895441Z [31m│[0m [0m "typeProperties": {} 2023-07-15T12:55:58.2895614Z [31m│[0m [0m } 2023-07-15T12:55:58.2895910Z [31m│[0m [0m} and error is Invalid linked service payload, the 'typeProperties' nested in payload is
null..
=============================
I found this online, need to modify for the Az storage account….
Here’s an example…
resource "azurerm_synapse_linked_service" "cosmos" {
name = "synsv-powerbi-uksouth"
synapse_workspace_id = azurerm_synapse_workspace.synapse.id
type = "Azure Cosmos DB (SQL API)"
type_properties_json = <<JSON
{
"connectionString": "${azurerm_cosmosdb_account.cosmos.connection_strings[0]}Database=${azurerm_cosmosdb_sql_database.cosmos.name}"
}
JSON
depends_on = [
azurerm_synapse_firewall_rule.synapse
]
}
==============================================
According the Terraform logs the below TF worked although I can’t see the newly created Synapse ‘linked service’ in the Azure Synapse Studio…
resource "azurerm_synapse_linked_service" "synapse_linked_service_datalake" {
depends_on = [module.add_synapse_firewall_rule0, azurerm_storage_data_lake_gen2_filesystem.datalake_fs, data.azurerm_storage_account.datalake, module.set_role_storage]
name = "linked-service-to_${data.azurerm_storage_account.datalake.name}"
synapse_workspace_id = azurerm_synapse_workspace.synapse.id
type = "AzureBlobStorage"
type_properties_json = <<JSON
{
"connectionString": "DefaultEndpointsProtocol=https;AccountName=${data.azurerm_storage_account.datalake.name};AccountKey=${data.azurerm_storage_account.datalake.primary_access_key};EndpointSuffix=core.windows.net"
}
JSON
/* integration_runtime {
name = azurerm_synapse_integration_runtime_azure.synapse_integration_runtime.name
} */
}
2
Answers
Terraform for Azure storage account (datalake) using 'default intergration runtime'....
}
It could be something like this:
}
You can also check out the official documentation on the Terraform Registry for more information on how to use this provider:
Let me know if it helps by accepting the answer.