azure - Azure 逻辑应用的 ARM 模板 - SQL 创建触发器
问题描述
是否可以为触发在 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 托管数据库。
解决方案
我遇到的问题是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"
}
}
}
}
推荐阅读
- ios - 如果应用程序在后台运行,则不会调用 continueUserActivity 方法
- java - 将标签添加到pdf文件java
- c# - 部分视图中的 ng-app 和 ng-controller 不起作用
- c# - 如何仅从 WPF MVVM 中的调度程序线程以外的线程更新可观察集合中的属性?
- php - 如何按月对mysql中的concat进行分组并显示?
- django - django-auth-ldap 成员组不工作
- python - jira python api问题与search_issues给出不同的结果
- javascript - 如何使用 javascript 和 php 在 $_GET 处获取数组?
- mysql - 在所有表中插入单个 table_name 作为列值
- bash - 如果找到,则使用 awk 替换特定列值