azure - 在azure服务器中执行存储过程

标签 azure stored-procedures azure-cosmosdb

如何在 Azure 服务器中执行示例存储过程。

我正在使用 cosmos db 模拟器,每当我尝试执行示例 sp 时,我都会收到此错误

Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted.

存储过程

function createToDoItem(itemToCreate) {
    var context = getContext();
    var container = context.getCollection();
    console.log("success");
    var itemToCreate={
        "Id": null,
        "UserAccountID": "1742",
        "FirstName": "Sanjeev",
        "LastName": "S",
        "Phone": "12345678",
        "Location": "",
        "StreetAddress": "vcbgvbvc",
       };

itemToCreate.partitionKey = "UserAccountID";

    var accepted = container.createDocument(container.getSelfLink(),
        itemToCreate,
        function (err, itemCreated) {
            if (err) throw new Error('Error test' + err.message);
            context.getResponse().setBody(itemCreated.id)
        });
    if (!accepted) return;
}

示例存储过程也无法获得所需的结果。链接问题 here

最佳答案

Sanjeev S,基于问题消息:

Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted.

它声称文档中的分区键需要与集合的分区键设置相匹配。

例如,您的集合的分区键是 /name

enter image description here

然后,您需要在插入的文档中排除 name 属性,并在执行 SP 时提供像这样的分区键。

enter image description here

输出:

enter image description here

关于azure - 在azure服务器中执行存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55789869/

相关文章:

mysql - 检查存储过程是否包含正确的表名

mysql - 单步执行mysql存储过程

Mysql - 过程执行失败而不是错误

azure - 查询cosmosDB : get last element in array

javascript - Azure Functions 中通过整数 SQL 查询 DocumentDB 不起作用

azure - Kusto 正则表达式查询电子邮件

Azure B2C - 在 Azure 中为不同用户类型设置多个登录的单一应用程序

azure - 如何访问 Azure API 管理中的路由参数

javascript - 解决异步/等待问题

Azure Web服务每隔几个小时更新一次相同的docker镜像