azure Terraform -创建Synapse链接服务

ejk8hzay  于 2023-08-07  发布在  其他
关注(0)|答案(2)|浏览(162)

我是新来的。
我在网上寻找例如在Terraform(提供商“hashicorp/azurerm”)为创建一个链接的服务在突触链接到:
Azure SQL Server 2016
我的代码不起作用...

>    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 }

字符串
我得到的错误…

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


空..

我在网上发现了这个,需要修改为阿兹存储帐户。
举个例子

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
  ]
}

根据Terraform日志,下面的TF工作了,尽管我在Azure Synapse Studio中看不到新创建的Synapse“链接服务”...

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
  } */

}

dbf7pr2w

dbf7pr2w1#

它可能是这样的:

resource "azurerm_synapse_linked_service_azure_sql_database" "example" {
  name                = "example"
  workspace_name      = azurerm_synapse_workspace.example.name
  resource_group_name = azurerm_resource_group.example.name

  connection_string = "Data Source=tcp:<your_server>.database.windows.net,1433;Initial Catalog=<your_database>;User ID=<your_username>;Password=<your_password>;Encrypt=true;TrustServerCertificate=false;Connection Timeout=30;"
}

resource "azurerm_synapse_linked_service_azure_data_lake_storage_gen2" "example" {
  name                = "example"
  workspace_name      = azurerm_synapse_workspace.example.name
  resource_group_name = azurerm_resource_group.example.name

  storage_account_name = azurerm_storage_account.example.name
}

字符串
}
您还可以查看Terraform Registry上的官方文档,了解有关如何使用此提供程序的更多信息:

如果接受答案会有帮助的话告诉我。

5cnsuln7

5cnsuln72#

Terraform for Azure storage account(datalake)using 'default integration runtime'...

resource "azurerm_synapse_linked_service" "synapse_linked_service_datalake" {
  depends_on           = [module.add_synapse_firewall_rule, data.azurerm_storage_account.datalake, module.set_role_storage, azurerm_synapse_role_assignment.role_synapse_role_assignments]
  name                 = "linked-service-to_${data.azurerm_storage_account.datalake.name}"
  synapse_workspace_id = azurerm_synapse_workspace.synapse.id
  #type                 = "AzureStorage"
  type                 = "AzureBlobFS"
  type_properties_json = <<JSON
    {
      "url": "https://${data.azurerm_storage_account.datalake.name}.dfs.core.windows.net"
    }
    JSON

  /* integration_runtime {
    name = azurerm_synapse_integration_runtime_azure.synapse_integration_runtime.name
  } */

字符串
}

相关问题