azure-cosmos-db-emulator-docker
azure-cosmos-db-emulator-docker copied to clipboard
Connection keeps hanging without setting connectionMode to Gateway
Describe the bug When I finished the container set up using following command, I can not connect to cosmos db using c# sdk. It will keep hanging when I am try to create a new db or collection.
Command to create container:
docker run \ --publish 8081:8081 \ --publish 10250-10255:10250-10255 \ --env AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=127.0.0.1 \ --name linux-cosmosdb-emulator \ --detach \ mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
Service code to connect to cosmos db
To Reproduce Steps to reproduce the behavior:
- dotnet new console
- dotnet add package Microsoft.Azure.Cosmos
using Microsoft.Azure.Cosmos;using CosmosClient client = new( accountEndpoint: "https://localhost:8081/", authKeyOrResourceToken: "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" );- Database database = await client.CreateDatabaseIfNotExistsAsync( id: "cosmicworks", throughput: 400 );
- dotnet run
Expected behavior
A new database named "cosmicworks" will be created.
Desktop (please complete the following information):
- OS: Windows 11
- Browser: Edge
**Docker Images Used: **
- Linux: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
**Arguments && Environment variables to start Docker:
--publish 8081:8081 \
--publish 10250-10255:10250-10255 \
--env AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=127.0.0.1 \
--name linux-cosmosdb-emulator \
--detach \
Additional context Reference: https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-develop-emulator?tabs=docker-linux%2Ccsharp&pivots=api-nosql
I updated to use Gateway as the connection mode and it succeed. But I am wondering why it can not be set to direct as it works when I am using the local cosmos db emulator.