Cosmos DB emulator returns ServiceUnavailable (503)

Renze Yu 47 Reputation points Microsoft Employee
2023-10-17T02:10:40.9733333+00:00

We meet error from Cosmos DB emulator "Response status code does not indicate success: ServiceUnavailable (503)" on Windows. This seems to be related with how fast we call it.

Our user scenario is in unit test. We connect our unit test to Cosmos DB emulator instead of real Azure Cosmos DB. The first step is to read bunch of files from JSON files, and set up database, containers, and items.

We find some calls will fail when creating them with error 503, which fails the later unit tests that relies on these data. The error only happens where preparing the data, so we suspect there is some capacity limit within it, but we cannot identify the root cause with the limited error message.

I see some similar issues reported in GitHub (e.g. https://github.com/Azure/azure-cosmos-dotnet-v2/issues/817), but cannot find a solution to it.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,911 questions
{count} votes

Accepted answer
  1. SSingh-MSFT 16,371 Reputation points Moderator
    2023-10-17T08:32:09.9+00:00

    Hi
    Renze Yu
    •,

    Welcome to Microsoft Q&A forum.

    As I understand, your Cosmos DB emulator returns ServiceUnavailable (503).

    Could you please try below:

    1). Try resetting data which will clean containers and database.

    2). Try increasing the emulator capacity.

    Use:

    First through the AZURE_COSMOS_EMULATOR_PARTITION_COUNT environment variable (here an extract on our docker compose):

    cosmos_db_service:

    container_name: cosmos_db

    image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest

    environment:

    • AZURE_COSMOS_EMULATOR_PARTITION_COUNT=20
    • AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true

    AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=127.0.0.1

    Second by defining a higher offerThroughput for each container (defined during our schema provisioning process):

    await client.database(env.vars.MICROSOFT_COSMOSDB_DATABASE).containers.createIfNotExists(

    { id: containerId },

    { offerThroughput: 10000 } // throughput values between 400 and 1000000 inclusive in increments of 100

    )

    Please try and let us know the result. Thank you.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.