How To Start Cosmos DB Emulator

How To Start Cosmos DB Emulator

In this Azure tutorial, we will discuss How To Start Cosmos DB Emulator. Along with this, we will also discuss the below topics.

  • How to start cosmosdb emulator from command line?
  • How to start CosmosDB Emulator automatically upon machine startup?
  • Cosmos DB Emulator Linux
  • Cosmos DB Emulator Download Windows 10
  • Cosmos DB Emulator Localhost Refused To Connect
  • Cosmos DB Local Emulator

How To Start Cosmos DB Emulator

Well, you are at the right place to know how to start a Cosmos DB emulator.

Assuming you have already installed the Azure Cosmos DB Emulator by now. If you have not yet installed it, you can download and install the Azure Cosmos DB Emulator now.

Once you have installed the Azure Cosmos DB Emulator successfully on your machine, you can follow the below two quick steps to start the Azure Cosmos DB Emulator.

  1. Click on the Start button.
  2. Search for the “Emulator” and click on the search result “Azure Cosmos DB Emulator” as highlighted below.
How to Start Azure Cosmos DB Emulator
How to Start Azure Cosmos DB Emulator

This is How do I open cosmos emulator?.

How to start cosmosdb emulator from command line?

You can also start the Azure Cosmos DB emulator from the command line.

  1. Open the Command prompt with Run as administrator mode.
  2. Go inside the Azure Cosmos DB installation folder by using the below command.
C:\WINDOWS\system32>cd C:\Program Files\Azure Cosmos DB Emulator

3. Now the run the below command.

C:\Program Files\Azure Cosmos DB Emulator>.\Microsoft.Azure.Cosmos.Emulator.exe /AllowNetworkAccess /Key=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM +4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==

How to start CosmosDB Emulator automatically upon machine startup?

Well, to start the Azure CosmosDB Emulator automatically, the Below information can help you.

  1. Use the below command as a batch file or include in a script.
"C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" /noui

2. Run it with the help of a task scheduler.

Cosmos DB Emulator Linux

You can run the Cosmos DB Emulator on docker for Linux which is in Preview.

As of now, SQL API is only supported in the case of Linux emulators.

Since Cosmos DB Linux Emulator is in preview, it is not suggested to use for production. Use Cosmos DB Windows Emulator for production purposes.

With the help of Azure Cosmos DB Linux Emulator, you can able to create/query data, easily execute the stored procedures, triggers, etc. Not only that you can easily provision and scale the container.

Develop, test your application with the help of Azure Cosmos DB Linux Emulator and then deploy them quickly to Azure cloud.

How to run the Linux Emulator on macOS

Follow the below steps to run the Linux Emulator on macOS.

  1. The first step is to get the IP address of your local machine using the below command.
ipaddr="`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -n 1`"

2. As the next step use the below command to pull the Docker image from the registry.

docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator

3. Finally, use the below configurations and run the Docker image.

docker run -p 8081:8081 -p 10251:10251 -p 10252:10252 -p 10253:10253 -p 10254:10254  -m 3g --cpus=2.0 --name=xyz-linux-emulator -e AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10 -e AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true -e AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=$ipaddr -it mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator

How to run the Linux Emulator on Linux OS

Well, to run the Linux Emulator on Linux OS, you can follow the below steps.

  1. The first step is to install the latest version of Docker using the below command.
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

2. The second step is to retrieve the ip address of your local machine using the below command. (This step is required in case the Direct mode setting is configured by using Cosmos DB SDKs (.NET, Java).)

ipaddr="`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -n 1`"

3. As the next step, you need to run the Docker image with the following configurations.

docker run -p 8081:8081 -p 10251:10251 -p 10252:10252 -p 10253:10253 -p 10254:10254  -m 3g --cpus=2.0 --name=xyz-linux-emulator -e AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10 -e AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true -e AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=$ipaddr -it mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator

Cosmos DB Emulator Download Windows 10

You can download Azure Cosmos DB Emulator for Windows 10 machines now.

Cosmos DB Emulator Localhost Refused To Connect

Sometimes, your Azure Cosmos DB Emulator localhost might not connect and you might get the error “No connection could be made because the target machine actively refused it.”. To fix this issue you need to follow the below information.

Cause of the Error

The cause of this error is, Your local Azure Cosmos DB Emulator is not running.

Cosmos DB Emulator Localhost Refused To Connect [Solution]

The solution to fix this error is, Just to check, if your local Azure Cosmos DB Emulator is running or not.

You can check this with the below url

https://localhost:8081/_explorer/index.html

This is how to fix the error Cosmos DB Emulator Localhost Refused To Connect.

Cosmos DB Local Emulator

Azure Cosmos DB local Emulator provides you with the opportunity to develop and test your application locally.

Download and install the Azure Cosmos DB Emulator to develop and test your application locally.

You may also like following the below articles

Wrapping Up

Well, in this article, we have discussed How To Start Cosmos DB Emulator and along with that we have also discussed the below topics

  • How to start cosmosdb emulator from command line?
  • How to start CosmosDB Emulator automatically upon machine startup?
  • Cosmos DB Emulator Linux
  • Cosmos DB Emulator Download Windows 10
  • Cosmos DB Emulator Localhost Refused To Connect
  • Cosmos DB Local Emulator

Hope you have enjoyed this article !!!