AZ-204Chapter 42 of 102Objective 2.1

Cosmos DB Emulator and Local Development

This chapter covers the Azure Cosmos DB Emulator, a local development tool that mimics the Azure Cosmos DB service for offline development and testing. Understanding the emulator is critical for the AZ-204 exam because it appears in questions about development tooling, local testing strategies, and cost optimization. Approximately 5-10% of exam questions touch on Cosmos DB development tools, including the emulator. You will learn how to install, configure, and use the emulator, its limitations compared to the cloud service, and how to integrate it into your CI/CD pipeline.

25 min read
Intermediate
Updated May 31, 2026

The Full-Scale Mock Airplane Cockpit

Imagine you are a pilot training for a new aircraft model. Instead of flying a real plane worth millions, you practice in a full-scale cockpit simulator that behaves exactly like the real thing. The simulator has the same instruments, same response times, same emergency procedures, and even the same engine sounds. You can practice every scenario — engine failure, crosswind landings, system malfunctions — without leaving the ground or endangering anyone. When you finally step into the real cockpit, everything feels familiar because the simulator mirrored the real aircraft's behavior down to the millisecond. In the same way, the Azure Cosmos DB Emulator is a local simulator that replicates the Cosmos DB service. It runs on your development machine, providing the same REST API, the same SDK behaviors, the same query engine, and the same data model as the cloud service. You can develop, test, and debug your application locally without incurring any Azure costs or needing an internet connection. The emulator uses a local SQLite-based storage engine to persist data, but it exposes the exact same endpoints (e.g., https://localhost:8081) and authentication (using a well-known key). Once your application works against the emulator, you switch the connection string to a real Azure Cosmos DB endpoint, and it runs identically — just like a pilot transitioning from a simulator to a real plane.

How It Actually Works

What is the Azure Cosmos DB Emulator?

The Azure Cosmos DB Emulator is a local desktop application that provides a high-fidelity emulation of the Azure Cosmos DB service. It runs on Windows, macOS, and Linux (via a Docker container). The emulator supports most of the features of the cloud service, including:

Creating and querying databases and containers

Using the SQL (Core) API, MongoDB API, Cassandra API, Gremlin API, and Table API

Configuring throughput (RU/s) at the database or container level

Using stored procedures, triggers, and user-defined functions (UDFs)

Multi-region replication simulation (limited to a single local instance)

Consistency levels: Strong, Bounded Staleness, Session, Consistent Prefix, and Eventual

How It Works Internally

The emulator uses a local SQLite database to store data and metadata. When you send a request via the Cosmos DB SDK or REST API to https://localhost:8081, the emulator processes it using the same query engine and indexing logic as the cloud service. It exposes the same REST API endpoints and SDK client configurations. The emulator's default account key is a well-known base64-encoded string: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==. This key is used for authentication in local development.

The emulator simulates the Cosmos DB resource hierarchy:

Account: Represented by the emulator instance

Database: Created via SDK or portal-like UI at https://localhost:8081/_explorer/index.html

Container: Created with a partition key and throughput settings

Items: JSON documents stored in containers

Key Components, Values, Defaults, and Timers

Default Endpoint: https://localhost:8081

Default Account Key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==

Default Consistency Level: Session (can be changed via the emulator UI or command line)

Supported APIs: SQL (default), MongoDB (port 10255), Cassandra (port 10350), Gremlin (port 8901), Table (port 8902)

Throughput Limits: The emulator supports up to 10,000 RU/s per container (cloud supports up to 1,000,000 RU/s per container with autoscale, but the emulator is capped for local performance)

Data Persistence: Data is stored in %LOCALAPPDATA%\CosmosDBEmulator on Windows or a Docker volume on Linux/macOS. The emulator can be started with the /AllowNetworkAccess flag to allow remote connections (useful for CI/CD)

Certificate: The emulator uses a self-signed SSL certificate. For SDK clients, you must disable certificate validation or trust the emulator's certificate.

Configuration and Verification Commands

Windows Installation:

Download the MSI from Microsoft or use the command line: msiexec /i https://aka.ms/cosmosdb-emulator

Start the emulator: "C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe"

Start with specific settings: CosmosDB.Emulator.exe /NoFirewall /AllowNetworkAccess /Key=<custom-key>

Docker (Linux/macOS/Windows):

docker run -p 8081:8081 -p 10251:10251 -p 10252:10252 -p 10253:10253 -p 10254:10254 -p 10255:10255 -p 10256:10256 -p 10350:10350 -p 8901:8901 -p 8902:8902 -m 3g --cpus=2 --name=cosmosdb mcr.microsoft.com/cosmosdb/linux/azure-cosmosdb-emulator

This maps all API ports and allocates 3GB memory and 2 CPUs.

Verification:

Open https://localhost:8081/_explorer/index.html in a browser (accept the self-signed certificate warning)

Use the .NET SDK to connect:

using Microsoft.Azure.Cosmos;
CosmosClient client = new CosmosClient("https://localhost:8081", "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==");

Use the Azure CLI (not directly, but via REST API calls)

How It Interacts with Related Technologies

The emulator integrates with: - Azure SDKs: The same NuGet packages (e.g., Microsoft.Azure.Cosmos) work against both the emulator and cloud. Simply change the URI and key. - Azure Functions: You can run Cosmos DB-triggered functions locally using the emulator as the trigger source. - Azure DevOps CI/CD: Use the emulator Docker image in build pipelines to run integration tests without provisioning a real Cosmos DB account. - Entity Framework Core: The Cosmos DB provider for EF Core works with the emulator.

Limitations of the Emulator

Scale: Limited to a single local machine; no multi-region replication (though it simulates the consistency levels)

Throughput: Maximum 10,000 RU/s per container; cannot test high-scale scenarios

Analytical Store: Not supported

Change Feed: Supported, but limited to a single partition; the change feed processor may behave differently at scale

Server-side Features: Stored procedures, triggers, and UDFs work but may have subtle differences in execution context

Latency: No network latency; performance tests on the emulator do not reflect real cloud performance

Data Size: Limited by local disk space; no automatic scaling

Exam Relevance

The AZ-204 exam expects you to:

Know the default endpoint and key

Understand that the emulator supports multiple APIs (SQL, MongoDB, Cassandra, Gremlin, Table)

Recognize that the emulator is for development and testing only, not production

Be aware of the /AllowNetworkAccess flag for CI/CD scenarios

Know that the emulator uses a self-signed certificate and how to handle it in SDK clients

Walk-Through

1

Install the Cosmos DB Emulator

On Windows, download the MSI installer from Microsoft and run it. The installer places the emulator in `C:\Program Files\Azure Cosmos DB Emulator`. On Linux or macOS, use Docker: pull the `mcr.microsoft.com/cosmosdb/linux/azure-cosmosdb-emulator` image and run it with the appropriate port mappings. Ensure your system meets the hardware requirements: at least 2 GB RAM and 2 CPU cores. After installation, start the emulator; on Windows, you can launch it from the Start Menu or command line. The emulator creates a local SQLite database file to persist data.

2

Configure the Emulator for Development

By default, the emulator listens on `https://localhost:8081` and uses a well-known account key. You can customize the key using the `/Key` command-line parameter. For multi-API support, the emulator opens additional ports: 10255 for MongoDB, 10350 for Cassandra, 8901 for Gremlin, and 8902 for Table. If you need to access the emulator from other machines (e.g., in a CI/CD pipeline), use the `/AllowNetworkAccess` flag. You can also disable the firewall prompt with `/NoFirewall`. The emulator's data directory can be changed with `/DataPath`.

3

Connect Your Application to the Emulator

In your application code, create a `CosmosClient` instance pointing to `https://localhost:8081` with the default key. For example, in C#: `new CosmosClient("https://localhost:8081", "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==")`. For other languages, use the same endpoint and key. Because the emulator uses a self-signed certificate, you must disable SSL certificate validation in the SDK or add the emulator's certificate to your trusted root store. In .NET, you can set `HttpClientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true` for development only.

4

Test and Debug Locally

Run your application against the emulator to create databases, containers, and items. You can use the Cosmos DB Explorer UI at `https://localhost:8081/_explorer/index.html` to view and manage data interactively. Test CRUD operations, queries, stored procedures, and change feed processing. The emulator supports all consistency levels; you can observe how session consistency works locally. Debug your code with breakpoints and inspect the requests and responses. Since the emulator runs locally, there is no network latency, making debugging faster.

5

Switch to Azure Cosmos DB in Production

Once your application is fully tested locally, update the connection string to point to your real Azure Cosmos DB account. Replace the emulator endpoint and key with the cloud endpoint and primary key from the Azure portal. Ensure your application handles SSL certificates properly in production (no need to disable validation). Also, consider that the cloud service has different throughput limits and pricing. Run a final set of integration tests against the cloud service to confirm behavior. The emulator's high fidelity ensures minimal surprises during this transition.

What This Looks Like on the Job

Enterprise Scenario 1: Offline Development by a Fintech Startup

A fintech startup building a transaction processing system uses Cosmos DB for its low-latency writes. Developers often work on flights or in areas with poor internet connectivity. They use the Cosmos DB emulator on their laptops to develop and run unit tests locally. Each developer runs the emulator via Docker, mapping ports to avoid conflicts. They use the /AllowNetworkAccess flag so that other services (like a local API gateway) can also connect. The emulator's SQLite backend provides enough throughput for their small test datasets (a few hundred transactions). They discovered that the emulator's change feed works differently under high partition counts, so they limit their test containers to a single partition. When they push code, the CI/CD pipeline spins up a fresh emulator container in Azure DevOps, runs integration tests, and tears it down. This approach saved them thousands of dollars in Cosmos DB costs during development.

Enterprise Scenario 2: CI/CD Integration for a Large E-Commerce Platform

A large e-commerce company uses Cosmos DB for product catalog and inventory. They have a strict policy that no production resources are used for testing. Their CI/CD pipeline uses the Cosmos DB emulator Docker image to run automated integration tests. The pipeline uses a docker run command with resource limits (-m 4g --cpus=4) to ensure consistent performance. They pre-populate the emulator with a seed dataset using the bulk import feature. Tests cover CRUD operations, stored procedures, and change feed scenarios. They encountered an issue where the emulator's self-signed certificate caused SSL errors in their .NET Core test runner. They resolved it by adding the emulator's certificate to the Docker container's trusted root store via a custom Dockerfile. They also learned that the emulator's maximum throughput of 10,000 RU/s is insufficient for load testing, so they use a separate cloud test account for performance tests.

Scenario 3: Multi-API Development with MongoDB and SQL

A mobile app backend uses both SQL API for core data and MongoDB API for analytics. Developers use the emulator to develop and test both APIs simultaneously. They start the emulator with default settings, which opens SQL on port 8081 and MongoDB on port 10255. In their code, they configure two separate clients: one for SQL and one for MongoDB. They found that while the emulator supports MongoDB wire protocol, it does not support all MongoDB aggregation pipeline stages — a known limitation. They had to adjust their queries to work within the emulator's capabilities. This early detection saved them from deploying broken code to production. They also use the emulator's UI to explore data across both APIs, which the cloud portal does not offer for MongoDB.

How AZ-204 Actually Tests This

AZ-204 Objective Coverage

The Cosmos DB Emulator is covered under objective 2.1: Develop solutions that use Cosmos DB storage. Specifically, exam questions may test: - Understanding the emulator's purpose: It is for local development and testing, not production use. - Default configuration: Endpoint https://localhost:8081, account key C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==. - Supported APIs: SQL (default), MongoDB, Cassandra, Gremlin, Table. - Limitations: Maximum 10,000 RU/s, no multi-region replication, no analytical store. - Certificate handling: Self-signed certificate; SDKs may need SSL validation disabled for development. - CI/CD usage: Docker container for automated testing; /AllowNetworkAccess flag.

Common Wrong Answers and Why

1.

Wrong: "The emulator supports up to 100,000 RU/s." Why chosen: Candidates confuse with the cloud service's autoscale maximum (1,000,000 RU/s) or the default manual throughput (400 RU/s). Reality: The emulator caps at 10,000 RU/s per container.

2.

Wrong: "The emulator can be used for production workloads with small data." Why chosen: Candidates think it's a lightweight cloud instance. Reality: The emulator is not designed for production; it lacks high availability, scalability, and SLA.

3.

Wrong: "The emulator supports all Cosmos DB features, including analytical store." Why chosen: Candidates assume it's a full mirror. Reality: Analytical store is not supported; multi-region writes are not simulated.

4.

Wrong: "The default account key is empty or can be any string." Why chosen: Candidates overlook the well-known key. Reality: The emulator uses a specific base64 key; while you can change it, the default is fixed.

Specific Numbers and Terms on the Exam

Default ports: 8081 (SQL), 10255 (MongoDB), 10350 (Cassandra), 8901 (Gremlin), 8902 (Table)

Default key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==

Maximum throughput: 10,000 RU/s

Consistency levels: All five supported (Strong, Bounded Staleness, Session, Consistent Prefix, Eventual)

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

Edge Cases and Exceptions

The emulator does not support the Table API in the Linux Docker image (it is Windows-only for Table). The exam may test this distinction.

The emulator's change feed works only for single-partition containers; multi-partition change feed is not fully simulated.

Stored procedures have a 5-second execution timeout in the emulator (same as cloud, but the emulator may be stricter).

The emulator can be run without a GUI on Windows using the /NoExplorer flag.

How to Eliminate Wrong Answers

If an answer mentions "production use" or "high availability," eliminate it.

If an answer claims support for analytical store or multi-region writes, eliminate it.

If an answer says the emulator's default throughput is 400 RU/s (the cloud default), it's wrong; the emulator has no default RU limit until you set it, but max is 10,000.

If an answer suggests using the emulator to test latency-sensitive scenarios, eliminate it because the emulator has zero network latency.

Key Takeaways

The Cosmos DB Emulator runs locally on Windows, macOS, and Linux (via Docker) for offline development and testing.

Default endpoint is https://localhost:8081; default account key is C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==.

Supports SQL, MongoDB, Cassandra, Gremlin, and Table APIs on different ports (8081, 10255, 10350, 8901, 8902 respectively).

Maximum throughput is 10,000 RU/s per container; not suitable for performance or load testing.

Does not support analytical store, multi-region replication, or full change feed for multi-partition containers.

Use the /AllowNetworkAccess flag for CI/CD scenarios; the Docker image is mcr.microsoft.com/cosmosdb/linux/azure-cosmosdb-emulator.

Always disable SSL certificate validation in development SDKs when connecting to the emulator.

Switch to the cloud service by changing the endpoint URI and account key in your application configuration.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

Cosmos DB Emulator

Runs locally on developer machine or in Docker

Free; no Azure subscription required

Maximum 10,000 RU/s per container

No multi-region replication; single local instance

Self-signed SSL certificate; may need to disable validation

Azure Cosmos DB Cloud Service

Runs in Azure datacenters globally

Pay-as-you-go pricing; requires Azure subscription

Up to 1,000,000 RU/s per container with autoscale

Multi-region replication with automatic failover

SSL certificate signed by public CA; no client-side changes needed

Watch Out for These

Mistake

The Cosmos DB Emulator is a cloud-based service with a free tier.

Correct

The emulator is a local application that runs on your machine. It does not require an internet connection and incurs no Azure costs. The free tier of Cosmos DB is a separate offering in Azure.

Mistake

The emulator supports all Cosmos DB features identically to the cloud.

Correct

The emulator supports most features but has limitations: no analytical store, no multi-region replication, maximum 10,000 RU/s, and limited change feed support for multi-partition containers.

Mistake

You must use the default account key; custom keys are not allowed.

Correct

You can specify a custom key using the `/Key` command-line parameter when starting the emulator. However, the default key is well-known and commonly used for development.

Mistake

The emulator only supports the SQL API.

Correct

The emulator supports SQL (default), MongoDB, Cassandra, Gremlin, and Table APIs. Each API uses a different port.

Mistake

The emulator can be used for load testing because it is free.

Correct

The emulator is not suitable for load testing because it runs on a single machine with limited resources (max 10,000 RU/s) and does not simulate network latency. Use a real Cosmos DB account for performance testing.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

How do I install the Azure Cosmos DB Emulator on Linux?

On Linux, you must use Docker. Run the command: docker run -p 8081:8081 -p 10251:10251 -p 10252:10252 -p 10253:10253 -p 10254:10254 -p 10255:10255 -p 10256:10256 -p 10350:10350 -p 8901:8901 -p 8902:8902 -m 3g --cpus=2 --name=cosmosdb mcr.microsoft.com/cosmosdb/linux/azure-cosmosdb-emulator. This maps all API ports and allocates 3GB memory and 2 CPUs. Ensure Docker is installed and running.

What is the default account key for the Cosmos DB Emulator?

The default account key is: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==. This is a well-known base64-encoded key. You can change it using the /Key command-line parameter when starting the emulator.

Can I use the Cosmos DB Emulator for production workloads?

No. The emulator is strictly for development and testing. It lacks high availability, scalability, and SLAs. It runs on a single machine and has a maximum throughput of 10,000 RU/s. For production, use the Azure Cosmos DB cloud service.

How do I connect to the Cosmos DB Emulator using the .NET SDK?

Create a CosmosClient with the endpoint https://localhost:8081 and the default key. Example: new CosmosClient("https://localhost:8081", "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="). You must disable SSL certificate validation because the emulator uses a self-signed certificate. In .NET, set ServerCertificateCustomValidationCallback to return true for development.

Does the Cosmos DB Emulator support the MongoDB API?

Yes. The emulator supports the MongoDB wire protocol on port 10255. You can connect using any MongoDB client or driver by pointing to mongodb://localhost:10255. Note that not all MongoDB aggregation pipeline stages are supported; check the documentation for limitations.

What is the maximum throughput I can set on a container in the emulator?

The maximum throughput is 10,000 RU/s per container. This is a limitation of the local emulator. In the cloud, you can set up to 1,000,000 RU/s with autoscale or 100,000 RU/s with manual throughput.

How do I use the Cosmos DB Emulator in a CI/CD pipeline?

Use the Docker image mcr.microsoft.com/cosmosdb/linux/azure-cosmosdb-emulator. In your pipeline, run a container with the necessary port mappings and resource limits. Use the /AllowNetworkAccess flag if needed. Then run your integration tests against the emulator endpoint. After tests, stop and remove the container.

Terms Worth Knowing

Ready to put this to the test?

You've just covered Cosmos DB Emulator and Local Development — now see how well it sticks with free AZ-204 practice questions. Full explanations included, no account needed.

Done with this chapter?