Azure Logic App HTTP触发返回元数据而非SQL查询结果求助
Azure Logic App HTTP GET返回运行元数据而非SQL查询结果的解决方法
问题根源分析
从你提供的Logic App配置代码来看,导致返回运行元数据而非SQL结果的核心问题有三个:
- Response动作设置了
operationOptions: "Asynchronous",开启异步响应模式后,Logic App会直接返回运行实例的元数据,而非等待流程执行完成后返回结果 - Response的
body表达式错误,使用@triggerOutputs()?['queries']获取触发器参数,而非SQL查询的输出结果 - Compose动作执行顺序错误,放在Response之后,无法对返回结果产生任何影响
修复步骤
- 移除异步响应配置:删除Response动作中的
operationOptions字段,确保Logic App以同步模式返回结果 - 修正结果获取表达式:将Response的
body改为@body('Execute_a_SQL_query_(V2)').ResultSets.Table1,直接读取SQL查询返回的Table1结果集 - 清理多余动作:移除不需要的Compose动作(若无需额外数据处理),或者调整其执行顺序到Response之前(如果需要先处理结果再返回)
修正后的完整配置
{ "definition": { "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", "contentVersion": "1.0.0.0", "triggers": { "When_a_HTTP_request_is_received": { "type": "Request", "kind": "Http", "inputs": { "method": "GET", "schema": {} } } }, "actions": { "Execute_a_SQL_query_(V2)": { "type": "ApiConnection", "inputs": { "host": { "connection": { "name": "@parameters('$connections')['sql-1']['connectionId']" } }, "method": "post", "body": { "query": "select * from dwh.dim_product where item_number='278'" }, "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('syn-dlr-eda-prd.sql.azuresynapse.net'))},@{encodeURIComponent(encodeURIComponent('Syndw'))}/query/sql" }, "runAfter": {} }, "Response": { "type": "Response", "kind": "Http", "inputs": { "statusCode": 200, "body": "@body('Execute_a_SQL_query_(V2)').ResultSets.Table1" }, "runAfter": { "Execute_a_SQL_query_(V2)": [ "Succeeded" ] } } }, "outputs": {}, "parameters": { "$connections": { "type": "Object", "defaultValue": {} } } }, "parameters": { "$connections": { "value": { "sql-1": { "id": "/subscriptions/c6119c4d-7517-4020-96e2-e98vjfj5d52/providers/Microsoft.Web/locations/southcentralus/managedApis/sql", "connectionId": "/subscriptions/c6119c0-96e2-e985d5c5xoxe2/resourceGroups/RG-DWH-DEV/providers/Microsoft.Web/connections/sql-1", "connectionName": "sql-1" } } } } }
验证要点
- 确认HTTP触发器的异步响应选项已禁用(在触发器设置中)
- 重新部署Logic App后,调用HTTP GET URL,此时应直接返回SQL查询的Table1结果集
- 查看运行历史,确认Response动作的输出为预期的SQL数据
内容的提问来源于stack exchange,提问作者KKU
相关产品推荐
相关产品推荐

