I have been battling this for a while now.
Scenario
We are using Cosmos SQL API and Cosmos Graph (Gremlin) in our project. For a long time we have been forced to use Azure resources when developing for the graph databases.
I whish to get rid of this for the LDE and run Azure CosmosDB emulator in docker using mcr.microsoft.com/cosmosdb/windows/azure-cosmos-emulator:latest image. The reason for docker is that we have some weird policies forced upon us from the IT Corp which made it impossible to get Azure Cosmos DB Emulator to work properly even for the SQLAPI. SQL Api works fine with the docker image. And I'm running docker compose.
After some investigation I found that the image is actually not looking for the environment variables like AZURE_COSMOS_EMULATOR_GREMLIN_ENDPOINT:true to be set. This was after investigating C:/CosmosDB.Emulator/Start.ps1 in the container. So i figured that I could fix this by simply replacing the Start.ps1 in the container, stop it, and commit it as a new image.
Which worked! Then I created a script for replicating the manual steps so my team does not have to do the same procedure. And now its not working the SQLAPI and Azure Cosmos DB Explorer works perfect but I cannot connect with Gremlin over port 8901 which worked earlier, once at least.
I have confirmed that the Start-CosmosDbEmulator command executed during start of the container has the -EnableGremlin flag set. But no luck, I just getting:
Unable to connect to the remote server ---> System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..
Is there anyone that has got this two work? I can't figure out what the issue is.
This is what I tried / have done:
- Certificates are imported and the https://localhost:8081/_explorer/index.html is trusted.
- The port setup in the docker-compose file is standard.
- I have tried to start container with docker run no luck.
- I 100% sure that the start-up command is rans with the -EnableGremlin set. Because of the transcript log file and investigating the Start.ps1 file in the container.
- The computemachine.config in container has the "IsGremlinEndpointEnabled":true for the container administrator user.
- I connect over localhost:8901 with the standard key and the database and container/collection is created.
- Querying with SQLAPI works find.
- Note: It worked fine the single time I got it to work also together with the Gremlin API functionality.
Docker Compose
version: '2.4' # Do not upgrade to 3.x yet, unless you plan to use swarm/docker stack: https://github.com/docker/compose/issues/4513
networks:
default:
external: false
ipam:
driver: default
config:
- subnet: "172.16.238.0/24"
services:
cosmosdb:
container_name: "azurecosmosemulator-sqlapi"
hostname: "azurecosmosemulator-sqlapi"
image: 'customimagename'
platform: windows
tty: true
restart: always
mem_limit: 3GB
ports:
- '8081:8081'
- '8900:8900'
- '8901:8901'
- '8902:8902'
- '10250:10250'
- '10251:10251'
- '10252:10252'
- '10253:10253'
- '10254:10254'
- '10255:10255'
- '10256:10256'
- '10350:10350'
environment:
- AZURE_COSMOS_EMULATOR_PARTITION_COUNT:10
- AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE:true
- AZURE_COSMOS_EMULATOR_GREMLIN_ENDPOINT:true
networks:
default:
ipv4_address: 172.16.238.246
volumes:
- '${hostDirectoryCosmosDBSQLAPI}:C:\CosmosDB.Emulator\bind-mount'
I haven't removed the environment variables that does not seems to have any purpose at all. But I have tried to have them removed several times if that had any affect in code that I cannot or have not yet investigated inside the container.
The transcript log
**********************
Windows PowerShell transcript start
Start time: 20220204162955
Username: User Manager\ContainerAdministrator
RunAs User: User Manager\ContainerAdministrator
Machine: AZURECOSMOSEMUL (Microsoft Windows NT 10.0.14393.0)
Host Application: powershell.exe -NoExit -NoLogo -Command C:\CosmosDB.Emulator\Start.ps1
Process ID: 1868
PSVersion: 5.1.14393.4583
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.4583
BuildVersion: 10.0.14393.4583
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is C:\CosmosDB.Emulator\bind-mount\Diagnostics\Transcript.log
INFO: Stop-CosmosDbEmulator
INFO: Start-CosmosDbEmulator -AllowNetworkAccess -NoFirewall -NoUI -Key C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw== -Consistency Session -Timeout 300 -EnableGremlin
Directory: C:\CosmosDB.Emulator\bind-mount
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2/4/2022 4:30 PM 804 CosmosDbEmulatorCert.cer
Key : GremlinEndpoint
Value : {http://azurecosmosemulator-sqlapi:8901/, http://172.16.238.246:8901/}
Name : GremlinEndpoint
Key : TableEndpoint
Value : {https://azurecosmosemulator-sqlapi:8902/, https://172.16.238.246:8902/}
Name : TableEndpoint
Key : Key
Value : C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
Name : Key
Key : Version
Value : 2.14.5.0
Name : Version
Key : IPAddress
Value : 172.16.238.246
Name : IPAddress
Key : Emulator
Value : CosmosDB.Emulator
Name : Emulator
Key : CassandraEndpoint
Value : {tcp://azurecosmosemulator-sqlapi:10350/, tcp://172.16.238.246:10350/}
Name : CassandraEndpoint
Key : MongoDBEndpoint
Value : {mongodb://azurecosmosemulator-sqlapi:10255/, mongodb://172.16.238.246:10255/}
Name : MongoDBEndpoint
Key : Endpoint
Value : {https://azurecosmosemulator-sqlapi:8081/, https://172.16.238.246:8081/}
Name : Endpoint
I hope there is someone out their that can point me in the right direction here. Maybe the solution is to skip this entirely and live with the fact that I have to create collections in Azure and work against does for the graph databases.
Greatful for any advice.