我已经阅读了这些关于运行 cosmosdb 模拟器的说明。说明。简而言之,我有运行 Windows 的虚拟机 VM。我在上面安装了 cosmosdb 模拟器。我从 ipconfig.exe 中检索了 IPv4 地址,我可以使用此命令启动模拟器。
Microsoft.Azure.Cosmos.Emulator.exe /AllowNetworkAccess /Key=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
C:\Users\User\AppData\Local\CosmosDBEmulator\
我什至按照建议首次启动时删除了数据。我创建了一个如下所示的 nodejs 应用程序。
应用程序.js
const axios = require('axios').default;
axios({
method: 'get',
url: 'http://10.0.2.15:8081/_explorer/index.html',
timeout: 5000
}).then(function (response) {
// handle success
console.log("success");
console.log(response);
}, e => {
console.log("ERROR: ")
console.log(e);
})
包.json
{
"name": "daniel",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "NODE_TLS_REJECT_UNAUTHORIZED=0 node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.20.0"
}
}
但是,当我npm run start
在 OSX 中的 VM 之外运行此节点应用程序时,请求超时。但是,我可以导航到https://10.0.2.15:8081/_explorer/index.html
VM 中的网站。如何使 nodejs 应用程序工作,以便它可以从 OSX 中的 VM 外部调用在 VM 中运行的 cosmosdb 模拟器?提前致谢。