【问题标题】:ARM Template for Azure Logic Apps - SQL Create TriggerAzure 逻辑应用的 ARM 模板 - SQL 创建触发器
【发布时间】:2019-06-27 12:02:25
【问题描述】:

是否可以为在 SQL 中触发创建记录的逻辑应用构建 ARM 模板?

我尝试了各种方法,但我总是遇到的问题是找不到连接。

我已经在 Azure 中创建了连接,并通过使用该连接的门户手动创建逻辑应用来证明它有效。

这是我最新的实现(暂时硬编码):

{
      "type": "Microsoft.Logic/workflows",
      "apiVersion": "2017-07-01",
      "name": "Data-Sync-Scheduler",
      "location": "[parameters('location')]",
      "properties": {
        "state": "Enabled",
        "definition": {
          "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
          "actions": {
            "HTTP": {
              "inputs": {
                "method": "GET",
                "queries": {
                  "scheduleId": "@{triggerBody()?['ScheduleId']}"
                },
                "uri": "<MY URL>"
              },
              "operationOptions": "DisableAsyncPattern",
              "runAfter": {},
              "type": "Http"
            }
          },
          "contentVersion": "1.0.0.0",
          "outputs": {},
          "parameters": {
            "$connections": {
              "defaultValue": {
                "sql": {
                  "connectionId": "/subscriptions/<ID>/resourceGroups/AZJACK001/providers/Microsoft.Web/connections/sql_2",
                  "connectionName": "sql_2",
                  "id": "/subscriptions/<ID>/providers/Microsoft.Web/locations/centralus/managedApis/sql"
                }
              },
              "type": "Object"
            }
          },
          "triggers": {
            "When_an_item_is_created": {
              "inputs": {
                "host": {
                  "connection": {
                    "name": "@parameters('$connections')['sql']['connectionId']"
                  }
                },
                "method": "get",
                "path": "/datasets/default/tables/@{encodeURIComponent(encodeURIComponent('[dbo].[Schedule]'))}/onnewitems"
              },
              "recurrence": {
                "frequency": "Minute",
                "interval": 1
              },
              "splitOn": "@triggerBody()?['value']",
              "type": "ApiConnection"
            }
          }
        }
      }
    }

编辑 1:这是一个 Azure SQL 托管数据库。

【问题讨论】:

  • SQL 服务器在哪里? Azure SQL 还是本地 SQL?
  • 抱歉 - Azure SQL

标签: azure azure-sql-database azure-logic-apps


【解决方案1】:

我遇到的问题是Logic App参数和ARM参数的区别,我的解决方法如下:

{
      "type": "Microsoft.Logic/workflows",
      "apiVersion": "2017-07-01",
      "name": "Data-Sync-Scheduler",
      "location": "[parameters('location')]",
      "properties": {
        "state": "Enabled",
        "definition": {
          "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
          "actions": {
            "HTTP": {
              "inputs": {
                "method": "GET",
                "queries": {
                  "scheduleId": "@{triggerBody()?['ScheduleId']}"
                },
                "uri": "<MY URL>"
              },
              "operationOptions": "DisableAsyncPattern",
              "runAfter": {},
              "type": "Http"
            }
          },
          "contentVersion": "1.0.0.0",
          "outputs": {},
          "parameters": {
            "$connections": {
              "defaultValue": {},
              "type": "Object"
            }
          },
          "triggers": {
            "When_an_item_is_created": {
              "inputs": {
                "host": {
                  "connection": {
                    "name": "@parameters('$connections')['sql_2']['connectionId']"
                  }
                },
                "method": "get",
                "path": "/datasets/default/tables/@{encodeURIComponent(encodeURIComponent('[dbo].[Schedule]'))}/onnewitems"
              },
              "recurrence": {
                "frequency": "Minute",
                "interval": 1
              },
              "splitOn": "@triggerBody()?['value']",
              "type": "ApiConnection"
            }
          }
        },
        "parameters": {
          "$connections": {
            "value": {
              "sql_2": {
                "connectionId": "/subscriptions/<MY ID>/resourceGroups/AZJACK001/providers/Microsoft.Web/connections/sql_2",
                "connectionName": "sql_2",
                "id": "/subscriptions/<MY ID>/providers/Microsoft.Web/locations/centralus/managedApis/sql"
              }
            },
            "type": "Object"
          }
        }
      }
    }

【讨论】:

    猜你喜欢
    • 2021-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-20
    • 1970-01-01
    • 2020-03-21
    • 1970-01-01
    相关资源
    最近更新 更多