使用Azure Logic Apps在Azuresqldatabase中插入行。

问题描述 投票:0回答:1

我有一个Azure SQL数据库,我想通过使用Logic Apps和Azure SQL数据库来执行插入、更新、删除操作。是否需要有一个网关 在Logic -app中连接Azure SQL DB到Sqlserver连接器时,我有三个属性 1)Id 2)名称 3)部门。Azure SqlDB

**When HTTP Request is Received Code:**
{
"headers": {
    "Accept": "application/json",
    "Content-Type": "application/json"
},
"properties": {
    "Department": {
        "type": "string"
    },
    "Name": {
        "type": "string"
    },
    "id": {
        "type": "integer"
    }
},
"type": "object"

}接收到Http请求

在 sql 连接器中,它显示出 Bad request。Insert -row Connector

属性的主体元素为空

{ "Department": null, "Name": null,  "id": null  }

插入行连接器的输出 {

"statusCode": 400,
"headers": {
    "Pragma": "no-cache",
    "x-ms-request-id": "3332d425-3e10-4f04-b618-63f359168acc",
    "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
    "X-Content-Type-Options": "nosniff",
    "X-Frame-Options": "DENY",
    "Timing-Allow-Origin": "*",
    "x-ms-apihub-cached-response": "false",
    "Cache-Control": "no-store, no-cache",
    "Date": "Mon, 04 May 2020 08:16:24 GMT",
    "Content-Length": "468",
    "Content-Type": "application/json",
    "Expires": "-1"
},
"body": {
    "status": 400,
    "message": "Microsoft SQL: Cannot insert the value NULL into column 'id', table '.dbo.Details'; column does not allow nulls. INSERT fails.\r\nclientRequestId: 3332d425-3e10-4f04-b618-63f359168acc",
    "error": {
        "message": "Microsoft SQL: Cannot insert the value NULL into column 'id', table 'dbo.Details'; column does not allow nulls. INSERT fails."
    },
    "source": "sql-eus2.azconn-eus2.p.azurewebsites.net"
}

}

注:我没有使用任何门路请指导我完成以上任务如果你有什么资源请告诉我。

逻辑应用-定义。设计师

以前的错误历史。错误:

我在Payload schema中传递的数据。在这里输入图像描述

azure azure-sql-database azure-functions azure-web-sites azure-logic-apps
1个回答
1
投票

出现这个错误是因为你是从azure门户运行触发器。当我运行触发器时,请看如下图所示。Triggering the HTTP Function from Azure portal> Error我遇到了以下错误"Microsoft SQL。不能将值NULL插入表'librarymanagement.dbo.DepartmentTable'的'id'列;该列不允许有空值。INSERT失败。"

为了正确调用HTTP触发器逻辑APP,你需要对它进行HTTP API调用。如果你刚刚学习,你可以使用POSTMAN来进行调用。以下是你需要做的步骤

  1. 从门户中复制Logic APP的网址。Copy HTTP URL

  2. 在postman中创建一个新的请求,并选择POST方法,然后粘贴步骤1中复制的url。同时粘贴正文,如图所示。Set Body

  3. 现在移动到标题,并设置如下所示的值。Set Headers

  4. 点击 "发送"。

© www.soinside.com 2019 - 2024. All rights reserved.