Closed goenning closed 3 years ago
The SDK uses the global endpoint, in your case https://localhost:9999/
to connect and request the account information. The global endpoint returns the endpoints the SDK should use. In a real account, you'd use https://youraccount.documents.azure.com
as global endpoint and you'd get 1 endpoint per region in the format https://youraccount-region.documents.azure.com
that the SDK would use.
Based on the logs, the problem is not the SDK.
DocDBTrace Information: 0 : Current WriteEndpoints = (https://172.21.0.2:8081/) ReadEndpoints = (https://172.21.0.2:8081/)
Those are the endpoints the Emulator is reporting, so the SDK will attempt to use that. Why the emulator is reporting the other endpoints with a different port is something that is outside the scope of this repo.
@goenning Could you share which command line arguments are you using to start the emulator?
Thanks for the description above, that makes sense. The emulator doesn't know it's on port 9999 because that mapping is done on a higher layer.
I'm using the emulator in docker-compose with this yaml. There must be a way to tell the emulator that we're using a different port then.
version: '2'
services:
cosmosdb:
image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
container_name: cosmosdb
restart: always
ports:
- 9999:8081
- 10251:10251
- 10252:10252
- 10253:10253
- 10254:10254
You should be starting the Emulator with the /Port argument from the documentation: https://docs.microsoft.com/en-us/azure/cosmos-db/emulator-command-line-parameters
I don't know how that is done on docker-compose.
Thanks for the info, I reached out to the emulator team and got this reply in case someone is looking for it.
We don't fully document how this can be done today but there are some options that allows you to pass other options to start the emulator.
For instance you can pass in the environment variable "AZURE_COSMOS_EMULATOR_ARGS" via Docker's "-e" option. This could take a list of emulator command line arguments as if you invoke the executable yourself (Command-line and PowerShell reference for Azure Cosmos DB Emulator | Microsoft Docs).
Another option is to override the default container's startup command, (see Docker options) and provide your own script/custom command that will replace it. In Windows Docker container this is a PowerShell script that you have access to. The custom logic will have to take the current command and add to it:
$startEmulatorCmd = "Start-CosmosDbEmulator -AllowNetworkAccess -NoFirewall -NoUI -Key $Key $startEmulatorOptions"
I hope the above steps help.
This is how it looks now:
version: '2'
services:
cosmosdb:
image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
container_name: cosmosdb
restart: always
ports:
- 9999:9999
- 10251:10251
- 10252:10252
- 10253:10253
- 10254:10254
environment:
AZURE_COSMOS_EMULATOR_ARGS: /Port=9999
Thanks for sharing the docker steps for future users.
Describe the bug I have the cosmos emulator running on a container using port 9999 instead of 8081. I'm using the C# client to connect to it, but it just hangs indefinitly. Looking at the output window, I see that it's trying to connect to port 8081 regardless of what my endpoint is.
Expected behavior It should connect to the correct port.
Actual behavior (include Exception or Stack Trace) It's connecting to the wrong port.
To Reproduce
Environment:
sha256:42dd3146bf324c4c5fe59b23352b65c19b3780795c28da97f524e86cc32aa5ed