We are trying to create an Azure Data Factory Linked Service for an Azure Batch account using Terraform. However, there is no native resource available in Terraform documentation for creating an Azure Batch Linked Service directly. To work around this, we attempted to use a custom-linked service. But, we are encountering an "Invalid Payload" error with the type "AzureBatch." We need assistance in resolving this issue and successfully creating the Azure Batch Linked Service using Terraform. Any guidance or solutions would be highly appreciated.
2 Answers
According to the sample template from terraform registry, I checked your code and tried to create Azure Batch linked service in my environment using azurerm_data_factory_linked_custom_service resource and was able to run it successfully as follows.
resource "azurerm_resource_group" "main" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_data_factory" "main" {
name = "examplejambar"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
identity {
type = "SystemAssigned"
}
}
resource "azurerm_storage_account" "main" {
name = "examplelocker"
resource_group_name = azurerm_resource_group.main.name
location = azurerm_resource_group.main.location
account_kind = "BlobStorage"
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_data_factory_linked_custom_service" "main" {
name = "mainsample"
data_factory_id = azurerm_data_factory.main.id
type = "AzureBlobStorage"
description = "test description"
type_properties_json = <<JSON
{
"connectionString":"${azurerm_storage_account.main.primary_connection_string}"
}
JSON
parameters = {
"foo" : "bar"
"Env" : "Test"
}
annotations = [
"test1",
"test2",
"test3"
]
}
Initialized & validated the configuration:

Executed terraform plan:

Executed terraform apply:

Deployed successfully:

5 Comments
connection_string property. @KarandeepSinghThe error is Invalid linked service payload, the "typeProperties" nested in payload is null.. shows that you have an issue with "connectionString":"${data.azurerm_storage_account.example.primary_connection_string}" config line.
Please double check that you have needed azurerm_storage_account, and data.azurerm_storage_account.example.primary_connection_string return correct connection string.
6 Comments
resource azurerm_storage_account to your terraform configconnection string. you can use terraform console command and run something like data.azurerm_storage_account.example.primary_connection_string and you should have the right connection string, if no - you need to update your terraform config. I believe you can check the connection string in the Azure UI.
resource "azurerm_data_factory_linked_custom_service" "example" { name = "azurebatch1" data_factory_id = azurerm_data_factory.example.id type = "AzureBatch" description = "test description" type_properties_json = <<JSON { "connectionString":"${data.azurerm_storage_account.example.primary_connection_string}" } JSON parameters = { "foo" : "bar" "Env" : "Test" } annotations = [ "test1", "test2", "test3" ] }