Azure Cosmos DB Emulator on a Local Area Network - azure-cosmosdb

I am trying to access Azure Cosmos DB Emulator through a Mac. The emulator is installed on Windows 10 machine. Both machines are obviously part of the local network. I am able to browse the emulator explorer on Windows 10 machine using the following addresses:
1) https://localhost:8081/_explorer/index.html
2) https://192.168.0.104/_explorer/index.html
However I am not able to browse the emulator explorer on Windows 10 machine using the following address:
1) https://192.168.0.104:8081/_explorer/index.html
I am getting following error message in browser:
The site can't be reached.
<192.168.0.104> refused to connect.
Same is the error message I am getting when I browse through Mac.
I have tried the following:
1) Activate "Private" firewall.
2) Turn off "Private" firewall.
3) Create a rule in firewall to allow inbound connections on port 8081.
4) Turn off all kinds of firewalls (Private, Domain, Public)
If anyone has tried to this before, please suggest what am I doing wrong or if it is even possible?

Use following command to generate a authorization key:
1) Microsoft.Azure.Cosmos.Emulator.exe /GenKeyFile=cosmosdbauthkey
2) Then shutdown the emulator if it is already running.
3) Then delete the emulator’s data directory at following location:
(C:\Users\user_name\AppData\Local\CosmosDBEmulator)
4) Restart the emulator with following command:
CosmosDB.Emulator.exe /AllowNetworkAccess /KeyFile=cosmosdbauthkey
Refer: https://learn.microsoft.com/en-us/azure/cosmos-db/local-emulator#command-line-syntax

Try installing the Cosmos DB emulator using the NoFirewall command.
CosmosDB.Emulator.exe /NoFirewall

Related

Google Cloud Shell - cannot connect - client network error

Running Windows 10 home I keep getting the following error message when I try to open Google Cloud Shell in Chrome:
Cannot connect to Cloud Shell due to a client network error. Please ensure you are connected to the internet and your network proxy settings allow connections to Cloud Shell.
In Firefox it's this error message (incl. incognito mode): An error occurred while communicating with the SSH server. Check the server and the network configuration.
I have tried:
Instances (VM on GCP/Compute Engine) in 2 different zones
Switching off firewall
Safe mode option for google cloud shell
Restart google cloud shell
Two different computers, on two different networks
No proxy server marked in LAN settings
Clearing cache on Chrome browser
CMD as Admin netsh winsock reset
CMD as Admin netsh int ip reset resetlog.txt
CMD as Admin netsh int ipv4 reset
CMD as Admin SFC/Scannow
CMD as Admin DISM /Online /Cleanup-Image /RestoreHealth
Using Chrome SSH extension - SSH for Google Cloud Platform
Connected through Tunnelbear VPN
Applied latest Windows Update patch - November 27, 2018—KB4467682
Deleted SSH keys in "Compute Engine -> Metadata"
Any suggestions are really appreciated!
Relevant troubleshooting link for others could be - https://cloud.google.com/compute/docs/ssh-in-browser#ssherror
More than an answer is a comment, if I understand you are try to open the Cloud Shell from the web browser, the browser is as not incognito mode?, disabling the default proxy configuration from your browser. Any relevant change from your firewall rule in the Win10 host?
I found that an Ad Blocker on my Firebox browser was preventing connection. If you disable it for Google Cloud then it works again.

DocumentDB Emulator Remote Connection

Do we have any way to connect document dB emulator from remote system ?
Can we create procedure , triggers , user defined functions etcs in document db emulator ?
The Emulator is meant for local dev scenarios, since it runs exposing a local port, you probably could (never tried, this is purely theoretical) work around the firewall and expose it, then connect from another system using your external IP and the exposed port.
There is also the local SSL certificate that you must solve (that probably is the biggest issue), though you could try with the TCP connection setting, might want to check this thread about which ports need to be opened.
Also, the Emulator does not have the entire feature set that the live service does:
The DocumentDB Emulator supports only a single fixed account and a well-known master key. Key regeneration is not possible in the DocumentDB Emulator.
The DocumentDB Emulator is not a scalable service and will not support a large number of collections.
The DocumentDB Emulator does not simulate different DocumentDB consistency levels.
The DocumentDB Emulator does not simulate multi-region replication.
The DocumentDB Emulator does not support the service quota overrides that are available in the Azure DocumentDB service (e.g. document size limits, increased partitioned collection storage).
As your copy of the DocumentDB Emulator might not be up to date with the most recent changes with the Azure DocumentDB service, please DocumentDB capacity planner to accurately estimate production throughput (RUs) needs of your application.
So, you are probably better off installing the emulator on the other system via the installer or Chocolatey and avoid all the problems.
UPDATE: My following attempted solution doesn't work. Connection Timeout, 192.168.0.101:8881 using the Node.js DocumentDB sdk. I think because of SSL. :/ Sorry. Leaving this "Answer" for documentation on what doesn't work, and if anyone knows how to bypass DocumentDB Emulator SSL.
I am trying to connect DocumentDB Emulator across my local network. (I dev on a virtual machine)
I am trying to do a port forward, to the 8081 local port that DocumentDB Emulator listens on. In Command Prompt (Run as Administrator)
netsh interface portproxy add v4tov4 listenaddress=192.168.0.101 listenport=8080 connectport=8081 connectaddress=127.0.0.1
192.168.0.101 is the network address of the PC.
Now I'm able to navigate to:
https://192.168.0.101:8080/_explorer/index.html and see the data explorer. Optimistic I can get this working for dev, with SSL turned off?
Also tried to use node.js http-proxy couldn't get it working with self-signed certificates. :(
Update, I actually got http-proxy working, but it only works if you start the servers in a specific order...
start api server
start proxy server (on windows box) with secure: true
make a failed connection
change proxy server (on windows box) to secure: false; restart;
now it's working... but useless for dev, because if you restart the API server after code change, the connection fails again.
Sample Node.js Proxy to be run on Windows box:
```
var fs = require('fs'),
httpProxy = require('http-proxy');
//
// Create the proxy server listening on port 443
//
httpProxy.createServer({
ssl: {
key: fs.readFileSync('valid-ssl-key.pem', 'utf8'),
cert: fs.readFileSync('valid-ssl-cert.pem', 'utf8')
},
target: 'https://localhost:8081',
secure: true // Depends on your needs, could be false.
}).listen(8881);
```
You just need to start the documentdb with additional parameters:
start "" "c:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" /AllowNetworkAccess /NoFirewall /Key=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
Checkout the documentdb docker file for more details: https://github.com/Azure/azure-cosmos-db-emulator-docker/blob/master/package_scripts/startemu.cmd

Azure SQL - localhost can't connect

I started coding an ASP.NET webapp (with Visual Studio 2015). I'm having problems with the connection to my Azure SQL database. I can connect to the database via MSSM Studio.
When I publish my app on the Azure webservice the app works fine. When I run my code locally I keep getting the following error:
SqlException: Cannot open server 'database' requested by the login. Client with IP address 'XX.XX.XX.XX' is not allowed to access the server. To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. It may take up to five minutes for this change to take effect.
Altough the firewall of the database service is set (I've even tried with range 0.0.0.0 too 255.255.255.255). On my computer port 1433 is allowed.
Any help is deeply appreciated.
The problem was solved by editing the username of the database connectionstring.
my_username#my_app.database.windows.net -> only worked published on Azure (not via localhost)
my_username#database.windows.com -> works published on Azure and with my localhost

Cannot connect (via http) to IIS app on Azure VM

I have created a SQL VM on Microsoft Azure and it's been like a walk in the park:
I was able to connect via RDP all the time. I installed an app to IIS and it was working ok.
Now, i wanted to connect from the outside world, but Chrome just gives me the page is not available error.
My DNS name is sqlmilos.cloudapp.net.
I took down windows firewall on windows server.
IIS is bound to port 80.
As I understand I connect to my VM via cloud service which was created at the same time as VM, and it has same dns name: sqlmilos.cloudapp.net
That cloud service has 2 input endpoints (shown in dashboard):
SQL : 23.102.171.184:5986
SQL : 23.102.171.184:63907
That 63907 port is for RDP and it's working, obviously.
I thought maybe I should bind IIS to 5986 port, just for test, but iis says that port is already used.
So, I was hoping that somebody could give me some pointers how to resolve this.
Best regards,
UPDATE:
I just realized that you can add you own endpoints to VM, so I added one for port 80, so now I have 3 ports open: 80, 5986 and 63907,
but I still cannot connect to application.

Accessing web server running in android emulator from local machine

I m trying to access a web server running on android emulator from my machine. I know the reverse i.e how to access the server running on local machine from android emulator ( using 10.0.2.2) . I have searched a lot about this stuff but couldn't get any relevant information.
When the server is up and running inside the emulator I can access it using 10.0.2.15:portNumber. I can do a telnet to the emulator but I wonder how that will be helpful.
Any suggestions on how to get connect to web server running inside the emulator.
Thanks
adb forward tcp:[pcPort] tcp:[androidPort]

Resources