I try to create a database in the local cosmosDB emulator but this fails to work. It throws an exception with the following message:
Response status code does not indicate success: InternalServerError (500); Substatus: 0; ActivityId: 36f6a95d-26d7-4ecd-9c81-f6df220f3cdc; Reason: (Unknown server error occurred when processing this request. ActivityId: 36f6a95d-26d7-4ecd-9c81-f6df220f3cdc, Microsoft.Azure.Documents.Common/2.14.0, Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, Windows/10.0.19042 cosmos-netstandard-sdk/3.24.1);
This error happens in my project as well as in an simple, empty console app only containing these lines of code:
using Microsoft.Azure.Cosmos;
namespace CosmosDBTest;
class Program
{
public static async Task Main()
{
using var client = new CosmosClient("<A local connection string>");
var response = await client.CreateDatabaseIfNotExistsAsync("test", 500);
var database = response.Database;
await database.CreateContainerIfNotExistsAsync("container1", "id");
}
}
The version of the emulator I use is 2.14.6. The version of the NuGet package is 3.26.1
What is causing this exception and how do I solve this? I has worked with older versions of the emulator in combination of an older version of the NuGet package. But before I downgrade the emulator and/or package, I want to find out if there is a better work around.
I haven't tried the demo application which is offered by the emulator. Funny enough as it is on a tab with the name ".NET" (and another tab .NET core next to it) the ".NET" example is written in the very old version .net core 2.1 which I don't have installed even.
Try resetting the Emulator, this looks like a malfunction on the Emulator itself. The HTTP 500 is coming from the Emulator, the SDK is just surfacing the response.
Reference: https://learn.microsoft.com/azure/cosmos-db/troubleshoot-local-emulator
If you installed a new version of the emulator and are experiencing errors, ensure you reset your data. You can reset your data by right-clicking the Azure Cosmos DB Emulator icon on the system tray, and then clicking Reset Data…. If that does not fix the errors, you can uninstall the emulator and any older versions of the emulator if found, remove C:\Program files\Azure Cosmos DB Emulator directory and reinstall the emulator.
Alternatively if resetting the data doesn't work, navigate to
%LOCALAPPDATA%\CosmosDBEmulator
location and delete the folder.