CosmosDB.InMemoryEmulator 4.0.14

dotnet add package CosmosDB.InMemoryEmulator --version 4.0.14
                    
NuGet\Install-Package CosmosDB.InMemoryEmulator -Version 4.0.14
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CosmosDB.InMemoryEmulator" Version="4.0.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CosmosDB.InMemoryEmulator" Version="4.0.14" />
                    
Directory.Packages.props
<PackageReference Include="CosmosDB.InMemoryEmulator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CosmosDB.InMemoryEmulator --version 4.0.14
                    
#r "nuget: CosmosDB.InMemoryEmulator, 4.0.14"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CosmosDB.InMemoryEmulator@4.0.14
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CosmosDB.InMemoryEmulator&version=4.0.14
                    
Install as a Cake Addin
#tool nuget:?package=CosmosDB.InMemoryEmulator&version=4.0.14
                    
Install as a Cake Tool

CosmosDB.InMemoryEmulator

A high-fidelity, in-memory implementation of the Azure Cosmos DB SDK for .NET — purpose-built for fast, reliable component and integration testing.

Drop-in replacements for CosmosClient, Database, and Container — full CRUD, SQL queries, LINQ, patch, batches, change feed, and more. No network, no emulator process, no Docker, no Azure subscription required.

Core Types

Type Purpose
InMemoryCosmos Recommended entry point — one-liner setup with full SDK fidelity, test setup, and fault injection
FakeCosmosHandler HTTP-level interceptor — zero production code changes, full SDK fidelity
InMemoryContainer Backing in-memory storage (used internally; direct usage deprecated in 4.0)
InMemoryCosmosClient Deprecated in 4.0 — use InMemoryCosmos.Create() instead

Quick Start

using CosmosDB.InMemoryEmulator;
using Microsoft.Azure.Cosmos;

// Recommended: InMemoryCosmos — one-liner, full SDK fidelity
using var cosmos = InMemoryCosmos.Create("my-container", "/partitionKey");

await cosmos.Container.CreateItemAsync(
    new { id = "1", partitionKey = "pk1", name = "Alice" },
    new PartitionKey("pk1"));

var iterator = cosmos.Container.GetItemQueryIterator<dynamic>(
    "SELECT * FROM c WHERE c.name = 'Alice'");

Multi-Container

using var cosmos = InMemoryCosmos.Builder()
    .AddContainer("orders", "/customerId")
    .AddContainer("products", "/categoryId")
    .Build();

var orders = cosmos.Containers["orders"];
var products = cosmos.Containers["products"];

Test Setup & Fault Injection

// Register UDFs, stored procedures, seed data
cosmos.SetupContainer("orders").RegisterUdf("myUdf", args => args[0]);

// Inject faults: 429 throttling, 503 errors, timeouts
cosmos.Handler.FaultInjector = req => new HttpResponseMessage((HttpStatusCode)429);

Features

Full CRUD, 125+ SQL functions, LINQ, bulk operations, transactional batches, change feed, patch operations, ETag concurrency, partition keys, TTL, fault injection, DI integration, state persistence, point-in-time restore, unique key policies, computed properties.

Documentation

Full documentation: GitHub Wiki

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CosmosDB.InMemoryEmulator:

Package Downloads
CosmosDB.InMemoryEmulator.JsTriggers

JavaScript trigger body interpretation for CosmosDB.InMemoryEmulator. Uses Jint to execute real Cosmos DB trigger JavaScript (getContext, getRequest, getResponse, getBody, setBody) inside your in-memory tests.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.14 185 5/7/2026
4.0.13 108 5/7/2026
4.0.12 110 5/7/2026
4.0.11 110 5/7/2026
4.0.10 112 5/7/2026
4.0.9 118 5/7/2026
4.0.8 497 4/29/2026
4.0.7 136 4/29/2026
4.0.6 3,030 4/26/2026
4.0.4 169 4/20/2026
4.0.2 140 4/20/2026
4.0.1 140 4/19/2026
4.0.0 580 4/19/2026
3.0.1 118 4/19/2026
2.0.190-preview.1 48 4/19/2026
2.0.189 120 4/18/2026
2.0.188 125 4/16/2026
2.0.187 546 4/16/2026
2.0.186 107 4/16/2026
2.0.185 104 4/16/2026
Loading failed