You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Terraform部署包含Liquid模板映射的标准Logic App

用Terraform部署包含Liquid Maps的标准Logic App方案

核心解决思路

Liquid Maps本质是存储在Logic App关联存储账户(或集成账户)中的资源,ARM模板默认不会导出这类内容,因此需要分开部署映射文件与Logic App,再在工作流中手动关联。

1. 上传Liquid Maps至存储账户(非集成账户场景)

标准Logic App的Liquid Maps默认存在其关联存储账户的azure-webjobs-hosts容器下的workflows/{logic-app-name}/maps路径中,用Terraform的azurerm_storage_blob资源直接上传本地映射文件:

# 定义Logic App关联的存储账户
resource "azurerm_storage_account" "logicapp_storage" {
  name                     = "your-storage-account-name"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

# 定位到存储映射的容器
resource "azurerm_storage_container" "logicapp_maps" {
  name                  = "azure-webjobs-hosts"
  storage_account_name  = azurerm_storage_account.logicapp_storage.name
  container_access_type = "Private"
}

# 上传单个Liquid Map文件
resource "azurerm_storage_blob" "order_map" {
  name                   = "workflows/your-logic-app-name/maps/order-transform.liquid"
  storage_account_name   = azurerm_storage_account.logicapp_storage.name
  storage_container_name = azurerm_storage_container.logicapp_maps.name
  type                   = "Block"
  source                 = "./local-maps/order-transform.liquid" # 本地映射文件路径
}

2. 在Logic App工作流中关联Liquid Map

在azurerm_logic_app_workflow资源的工作流定义里,给Liquid操作指定mapName(即映射文件名,不带.liquid后缀):

resource "azurerm_logic_app_workflow" "order_processor" {
  name                = "your-logic-app-name"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name

  definition = jsonencode({
    "$schema" = "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#"
    "contentVersion" = "1.0.0.0"
    "triggers" = {
      "HTTP_Trigger" = {
        "type": "Request",
        "kind": "Http",
        "inputs": {
          "schema": {}
        }
      }
    },
    "actions" = {
      "Transform_Order_Data" = {
        "type": "Liquid",
        "inputs": {
          "content": "@triggerBody()",
          "map": {
            "name": "order-transform" # 对应上传的映射文件名(无后缀)
          }
        },
        "runAfter": {}
      }
    }
  })
}

3. 集成账户场景下的处理(可选)

如果你的Logic App用集成账户统一管理Liquid Maps,直接用azurerm_integration_account_map创建映射:

resource "azurerm_integration_account_map" "order_map" {
  name                     = "order-transform-map"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  integration_account_name = azurerm_integration_account.example.name
  map_type                 = "Liquid"
  content                  = file("./local-maps/order-transform.liquid")
  content_type             = "application/json"
}

然后在工作流的Liquid操作中,指定集成账户类型的映射:

"map": {
  "name": "order-transform-map",
  "type": "IntegrationAccount"
}

关键注意事项

  • 确保Logic App的系统身份拥有存储账户的Storage Blob Data Contributor权限,否则无法读取映射文件;
  • 若使用集成账户,Logic App必须关联该集成账户(通过integration_account_id参数配置)。

内容的提问来源于stack exchange,提问作者Sotades

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 01:51:02