How to get cosmosdb emulator to expose port to nodejs application running on OSX?

194 views Asked by At

I have read these instructions for running the cosmosdb emulator. instructions. In short I have virtual box VM running windows. I installed the cosmosdb emulator on that. I retrieved the IPv4 address from ipconfig.exe I can start the emulator with this command.

Microsoft.Azure.Cosmos.Emulator.exe /AllowNetworkAccess /Key=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==

I even deleted the data at C:\Users\User\AppData\Local\CosmosDBEmulator\ as was suggested to do for first time startup. I created a nodejs application that looks like this.

app.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);
  })

package.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"
  }
}

However when I run npm run start for this node application outside the VM in OSX the request times out. I can however navigate to the website https://10.0.2.15:8081/_explorer/index.html within the VM. How do I make the nodejs application work so that it can call the cosmosdb emulator running in the VM from outside the VM in OSX? Thanks in advance.

0

There are 0 answers