Tag: azure cosmosdb

如何阻止Azure DocumentDB Emulator将本地主机redirect到HTTPS?

每当我启动它,它会发送一个HSTS头 ,这意味着每个请求现在从http://localhostredirect到https://localhost 。 在使用node.js进行本地开发时,这是一个PITA。 有没有办法阻止它这样做?

Azure中的SQL Query DocumentDB由整数不起作用的函数

我在Azure函数中使用JavaScript语言。 当使用Cosmos DB作为input时,我无法通过整数作为variables来查询。 例如,我有以下几点: 使用Azure Cosmos DB作为我的input(公司)的function设置。 这是设置分区键为{partitionKey}和我的SQL查询作为SELECT * FROM c where c.random = {randomId} 。 在函数的代码中,我发送了以下作为我的testing数据: { "randomId": 1, "partitionKey": "prospect" } 有了这个,我没有得到任何结果。 我已经证实,我有一个random值为1的对象。 如果我要random添加一个值为"1" ,那么以下内容将起作用: { "randomId": "1", "partitionKey": "prospect" } 我已经用DocumentDB API和MongoDB API尝试了这个,因为这个绑定是内置到Azure函数中的,所以不要紧。 我用不同的数据集看到的趋势是,当您将整数参数绑定到查询或文档ID字段中时,查询不起作用。 任何想法如何解决这一问题? 编辑: 我已经证实这在C#中可用的文档。

尝试从DocumentDb中删除文档时发生错误的请求错误

当我尝试从nodejs应用程序中的DocumentDb中删除一个文档时,它给出了以下错误的请求错误。 {“code”:“BadRequest”,“message”:“Message:{\”Errors \“:[\ xml-partition-key头中提供的分区键比在集合中定义的分量要less。] } \ r \ nActivityId:fe385556-c91b-49a6-88ca-728a807b64ad,请求URI:/ apps / 63e70998-1c00-470e-8093-b4ef0dac16b1 / services / 2f865af8-4b67-4b6f-9919-9caf5a78d60c / partitions / 75008c63-10a3- 4ad3-85b7-d22883819270 /副本/ 131467476052794282p“} DBHandler.prototype.removeItem = function(item,callback){ this.client.deleteDocument(item._self, item, function(err, doc){ if (err) { LogUtils.error("DBHandler.removeItem "+err.body); } else { callback(null, "success remove Item"); } }); }

CosmosDB – 以编程方式查询消耗的RU / s?

我试图得到关于消费RU /第二集合水平的信息 ,不幸的是,当我查询与node.js documentdb模块的集合信息,与代码 var client = new DocumentDBClient(host, { masterKey: masterKey }); client.readCollection(collection._self, function(err, item) { if (err) { console.log(err); } else { console.log(item); } }); 我只获得如下的基本信息 { id: 'myCollection', indexingPolicy: { indexingMode: 'consistent', automatic: true, includedPaths: [ [Object] ], excludedPaths: [] }, _rid: 'ku8SANRCfwA=', _ts: 1505295711, _self: 'dbs/ku8SAA==/colls/ku8SANRCfwA=/', _etag: '"00008b00-0000-0000-0000-59b8fd5f0000"', _docs: 'docs/', _sprocs: […]

如何使用Loop在Cosmos-DB / Document-DB中执行存储过程?

我有JSON喜欢 { "id": "58d99ca3231f13b9ecbbbca4", "50records": [ { "aomsLineNbr": 1, "licenses": [ { "productKey": "84fc2cde-9735-4cea-b97a-3cd627d3d0a5", "aid": "someAid" } ] } ] } 我想在aid的基础上取logging。 50record可以有多个对象, licenses也可以有多个对象。 我构build查询为"SELECT * FROM orders o WHERE o['50records'][0].licenses[0].aid='someAid'" 我怎样才能循环这50records和licenses来search所有可用的对象? 以下是我的商店程序: function getOrdersByAidCollection(aid){ var context = getContext(); var collection = context.getCollection(); var link = collection.getSelfLink(); var response = context.getResponse(); var query = "SELECT […]

使用Node.js通过ID从DocumentDB读取文档失败

我试图通过使用文档ID从DocumentDB读取单个文档。 集合有四个字段, author是分区键。 { "id": string, "author": string, "title": string, "year": int } 我有两个函数来读取存储在DocumentDB中的logging。 queryCollectionByBookId通过文档ID读取单个文档, queryCollectionGetBooks返回集合中的所有文档。 var dbutils = { queryCollectionByBookId: function(client, documentUrl) { return new Promise((resolve, reject) => { client.readDocument(documentUrl, function(err, doc) { if (err) { reject(err); } else { resolve(doc); } }); }); }, queryCollectionGetBooks: function(client, collectionUrl) { return new Promise((resolve, reject) => […]

移动服务+ DocumentDB附件

这是我的堆栈: iOS和Android应用程序 DocumentDB 由Javascript支持的移动服务 由Javascript支持的Azure站点 我正在做的是从我们的应用程序中抽象出DocumentDB的知识,因为我们正在构build白色标签解决scheme,而且我们可能需要即时扩展DocumentDB实例。 使用抽象types的服务,我们基本上可以根据从应用程序发送的某些数据来分割我们的docdb实例。 现在这将包括2个我想要创build移动服务的操作。 一个获取JSON数据,另一个获取与文档关联的附件。 这是我的麻烦所在。 我有一个只能在NodeJS中部署的传递服务。 我喜欢与移动服务相关的安全模型,所以我想调整我的代码。 问题在于将DocDB响应传递给移动服务响应。 首先是移动服务默认标题试图设置和失败,所以我暂时覆盖该function。 现在移动服务从不响应,直到发生超时。 这是一个代码片段: exports.get = function (req, res) { … // .then().fail() always pushed into the fail() block, but if I use the 2 function in .then() way it works. client.readMediaAsync(mediaUrl).then( // Success function (media) { // Set up caching and proxy […]

备份在documentdb中

我需要对当前的集合进行快照,然后在documentdb中的任何时间点进行恢复。 可用的选项正在使用Azure迁移工具。 是否有可能通过我的应用程序内置节点调用API来做到这一点?

Azure Cosmos DB:TypeError:无法读取未定义的属性'electionId'

我用mongodb后端使用Azure Cosmos DB。 我一直在收到这个错误。 Exception has occurred: Error TypeError: Cannot read property 'electionId' of undefined at ReplSetState.update (c:\dev\3dshoppers.backend\node_modules\mongodb-core\lib\topologies\replset_state.js:371:70) at Server._handleEvent (c:\dev\3dshoppers.backend\node_modules\mongodb-core\lib\topologies\replset.js:421:45) at Server.g (events.js:291:16) at emitOne (events.js:96:13) at Server.emit (events.js:188:7) at c:\dev\3dshoppers.backend\node_modules\mongodb-core\lib\topologies\server.js:297:14 at c:\dev\3dshoppers.backend\node_modules\mongodb-core\lib\connection\pool.js:457:18 at _combinedTickCallback (internal/process/next_tick.js:73:7) at process._tickCallback (internal/process/next_tick.js:104:9) 我正在使用mongodb@2.2.19。 如果我更新npm包到最新版本,我得到不同的错误('MongoError:池被毁坏')。 我觉得Cosmos DB有一些问题…… 这在replset_state.js的这一行发生。 var currentElectionId = self.set[self.primary.name.toLowerCase()].electionId; 编辑:我能够重现以下两个文件的错误。 server.js // packages const express […]

如何解决MongoError:池连接到CosmosDB时被破坏

我有Node.js服务,我正在使用mongo-API与Document / Cosmos DB进行通信。 我的服务运行良好,并执行所有的crud操作,但1分钟后,从服务抛出一些mongo错误。 /document-db-service/node_modules/mongodb/lib/utils.js:123 process.nextTick(function() { throw err; }); ^ MongoError: pool destroyed at Pool.write (/document-db-service/node_modules/mongodb-core/lib/connection/pool.js:922:12) at Cursor._find (/document-db-service/node_modules/mongodb-core/lib/cursor.js:286:22) at nextFunction (/document-db-service/node_modules/mongodb-core/lib/cursor.js:584:10) at Cursor.next [as _next] (/document-db-service/node_modules/mongodb-core/lib/cursor.js:692:3) at fetchDocs (/document-db-service/node_modules/mongodb/lib/cursor.js:856:10) at toArray (/document-db-service/node_modules/mongodb/lib/cursor.js:883:3) at Cursor.toArray (/document-db-service/node_modules/mongodb/lib/cursor.js:836:44) at exports.getDocsOfCollections (/document-db-service/services/collections.js:273:10) at Layer.handle [as handle_request] (/document-db-service/node_modules/express/lib/router/layer.js:95:5) at next (/document-db-service/node_modules/express/lib/router/route.js:137:13) 我无法理解为什么会出现这个错误。请提出解决此错误所需的更改。