我正在 azure 门户中编写 Azure Cosmos DB 存储过程,我正在检查它最初可以给出的最大响应大小是多少,后来它给了我 4.8 MB 响应,任何大小都显示消息大小太大的错误。稍后在 5 分钟后执行相同的程序和相同的参数,它显示页面尺寸过大的错误。
// SAMPLE STORED PROCEDURE
function sample(prefix) {
var collection = getContext().getCollection();
// Query documents and take 1st item.
var isAccepted = collection.queryDocuments(
collection.getSelfLink(),
'SELECT r.data.truckSerialNo FROM root r',{pageSize : -1},
function (err, feed, options) {
if (err) throw err;
// Check the feed and if empty, set the body to 'no docs found',
// else take 1st element from feed
if (!feed || !feed.length) {
var response = getContext().getResponse();
response.setBody('no docs found');
}
else {
console.log(feed.length);
var response = getContext().getResponse();
var body = { prefix: prefix, feed: feed };
var str = {};
str.x1 = body ;
str.x2 = body ;
response.setBody(JSON.stringify(str));
}
});
if (!isAccepted) throw new Error('The query was not accepted by the server.');
}
和错误
无法执行集合 iotcollection 的存储过程 testProcedure: {"code":400,"body":"{\"code\":\"BadRequest\",\"message\":\"Message: {\\"Errors \\":[\\"执行函数时遇到异常。异常 = 错误:由于 \\\\"Body\\\\",结果消息会太大。从脚本返回当前消息并使用继续令牌调用再次脚本或修改您的脚本。\\r\\n堆栈跟踪:错误:结果消息将因 \\\\"Body\\\\" 而太大。从脚本返回当前消息并使用延续令牌调用再次脚本或修改您的脚本。\\n at validateSize (bulkUpsert_v_1_0.js:177:25)\\n at setValueInternal (bulkUpsert\\"]}\r\nActivityId:d61226ab-4d5e-4a3d-aa09-83351649ce4c, Request URI: /apps/59d3b9ef-17ca-4bbf-8a11-39d0199a8d29/services/1b26e00f-1f51-4d34-88ec-4090b8e7db00/partitions/45a313b7-2cf2-419e-9885-48bf9cfe6277/ replicas/131862936473830809p/,RequestStats:\r\nRequestStartTime:2018-11-10T06:41:26.3320532Z,尝试的区域数:1\r\n,SDK:Microsoft.Azure.Documents.Common/2.1.0.0\"} ","activityId":"d61226ab-4d5e-4a3d-aa09-83351649ce4c","substatus":413}}","activityId":"d61226ab-4d5e-4a3d-aa09-83351649ce4c","substatus":413}}","activityId":"d61226ab-4d5e-4a3d-aa09-83351649ce4c","substatus":413}