Closed diegosasw closed 5 months ago
This is the wrong repository, we do not handle Emulator specific issues.
Please consider: https://github.com/Azure/azure-cosmos-db-emulator-docker
Thanks. This may be an emulator specific issue, but shouldn't the SDK throw an exception or similar and not simply hang when trying to create a database?
@diegosasw An async application does not hang. If that is the case, then the problem is not the SDK but the .NET TaskScheduler in the machine/environment. Async operations are enqueued on the TaskScheduler and executed as threads become available.
So either the application is blocking threads, thus preventing the TaskScheduler from executing the async operations (application bug) or what you mention as a "hang" is not a proper "hang" but rather an operation that is in course, just taking longer than what you'd expect.
If you change the endpoint to a real account instead of the emulator and the problem persists, then it's probably the first one.
My hunch is that the problem is the latter. The SDK has retry semantics that are designed to provided high availability when connecting to a real service endpoint. The SDK might be retrying and never actually able to connect, you can add a CancellationToken to your operation to stop the retries.
CancellationTokenSource source = new CancellationTokenSource(TimeSpan.FromSeconds(120));
await cosmosClient.CreateDatabaseIfNotExistsAsync("foo", source.Token);
You can enable traces if you want to debug further, they should show the activity on the SDK.
Version 3.41.0
Describe the bug Unable to create or read databases using the SDK and CosmosDb emulator by following steps at https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-develop-emulator?tabs=docker-linux%2Ccsharp&pivots=api-nosql
To Reproduce This repo reproduces it https://github.com/diegosasw/cosmosdb-sample/tree/77d18b9b1861201b5e51003825540795ca37a7d7
Expected behavior It should create the database, be able to read it, or at least throw an exception informing on why it can't.
Actual behavior It hangs, no error, nothing.
Environment summary SDK Version: .NET 8 OS Version (e.g. Windows, Linux, MacOSX): Windows 11
Additional context More info at the above sample repository. Is there any basic .NET app using this SDK and interacting with CosmosDb docker emulator? I am new to CosmosDb and, after reading Microsoft documentation, I am unable to run a simple console app using the docker emulator.