Wednesday 6 April 2022

Client hangs connecting to the Cosmos DB emulator running as a Linux container

 I had created a docker-compose file for building a full environment which included a Cosmos DB emulator. However I found the client code - running locally on Visual Studio could not connect to the emulator. It would hang indefinitely (even with HTTP request timeouts overriden in the Client Factory).

I ran the emulator as a local service (not containerised) and this worked, indicating a problem specific to the container.

I found the error was the missing environment variable

AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE

This is required otherwise the emulator returns an IP address the client cannot connect to.

My docker-compose file now included the following variables:

environment:
      - AZURE_COSMOS_EMULATOR_PARTITION_COUNT=3
      - AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true
      - AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=${COSMOS_ADDRESS_OVERRIDE:?IPAddress}



No comments:

Post a Comment