0

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.

Reference:- https://learn.microsoft.com/en-us/azure/templates/microsoft.datafactory/factories/linkedservices?pivots=deployment-language-terraform#azurebatchlinkedservice-2

enter image description here

2
  • Can you provide the code here instead of image. @Karandeep Singh Commented Jul 20, 2023 at 8:06
  • 1
    Hi@Jahnavi this is the code ### 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" ] } Commented Jul 20, 2023 at 9:40

2 Answers 2

1

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:

enter image description here

Executed terraform plan:

enter image description here

Executed terraform apply:

enter image description here

Deployed successfully:

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

Hi Jahnavi thanks for your suggestion but the example that you have provided it will create a linked service for blob storage not for batch account. we want to create a linked service for batch account, please see the description carefully. Thanks
But in the connection string I can see that it is linking to storage account. How are you trying to link it with the batch account? @KarandeepSingh
okay, so can u give me the solution for this, I want to link it with the batch account
Did you try adding the connection string of batch account under connection_string property. @KarandeepSingh
We have found the solution for this. There is no need to provide a connection string.
0

The 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

yes @zombi_man , so can u please give me a solution for this
what should be the correct value for the string if we are creating a linked service for a batch account?
@KarandeepSingh, if you don't have storage account, please check the answer of @jahnavi and add resource azurerm_storage_account to your terraform config
we have a storage account and batch account is using that storage account, but now we want to link that batch account with the data factory using a linked service.
ok, if you already have it please use the correct data resource for getting proper connection 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.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.