Soenneker.Cosmos.Copy 11.0.340

Prefix Reserved
dotnet add package Soenneker.Cosmos.Copy --version 11.0.340
                    
NuGet\Install-Package Soenneker.Cosmos.Copy -Version 11.0.340
                    
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="Soenneker.Cosmos.Copy" Version="11.0.340" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Cosmos.Copy" Version="11.0.340" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Cosmos.Copy" />
                    
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 Soenneker.Cosmos.Copy --version 11.0.340
                    
#r "nuget: Soenneker.Cosmos.Copy, 11.0.340"
                    
#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 Soenneker.Cosmos.Copy@11.0.340
                    
#: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=Soenneker.Cosmos.Copy&version=11.0.340
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Cosmos.Copy&version=11.0.340
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Cosmos.Copy

Copies documents between Azure Cosmos DB containers or replaces the contents of one database from another.

Installation

dotnet add package Soenneker.Cosmos.Copy

Registration

using Soenneker.Cosmos.Copy.Abstract;
using Soenneker.Cosmos.Copy.Registrars;

services.AddCosmosCopyUtilAsSingleton();

ICosmosCopyUtil copy = serviceProvider.GetRequiredService<ICosmosCopyUtil>();

AddCosmosCopyUtilAsScoped() is also available. Both registrations add the Cosmos suite dependencies as singletons.

Copy a container

await copy.CopyContainer(
    sourceEndpoint: sourceEndpoint,
    sourceAccountKey: sourceKey,
    sourceDatabaseName: "production",
    sourceContainerName: "orders",
    destinationEndpoint: destinationEndpoint,
    destinationAccountKey: destinationKey,
    destinationDatabaseName: "staging",
    destinationContainerName: "orders",
    cutoffUtc: DateTimeOffset.UtcNow.AddDays(-30),
    numTasks: 25,
    cancellationToken: cancellationToken);

Documents are upserted, so documents already present in the destination with the same id and partition key are replaced. Existing destination documents that are not returned by the source query remain in place.

When cutoffUtc is supplied, the source query requires a createdAt property and copies documents where createdAt >= cutoffUtc. Omit it to copy every document.

Replace a database

var containerOptions = new[]
{
    new ContainerCopyConfig { ContainerName = "audit", Exclude = true },
    new ContainerCopyConfig
    {
        ContainerName = "orders",
        CutoffUtc = DateTimeOffset.UtcNow.AddDays(-7)
    }
};

await copy.CopyDatabase(
    sourceEndpoint,
    sourceKey,
    "production",
    destinationEndpoint,
    destinationKey,
    "staging",
    cutoffUtc: DateTimeOffset.UtcNow.AddDays(-30),
    containerConfigs: containerOptions,
    cancellationToken: cancellationToken);

CopyDatabase is destructive: it deletes every container in the destination database before copying. An excluded source container is not recreated. The source and destination database cannot be the same.

A per-container cutoff overrides the global cutoff. Container names in containerConfigs are matched case-insensitively and must be unique.

Container compatibility

Destination containers are created with /partitionKey as the partition-key path and without dedicated throughput. The utility copies documents, not the source container's partition-key definition, indexing policy, unique keys, TTL, throughput, or other settings. Use it only when /partitionKey is valid for the documents being copied, and configure any additional destination settings separately.

The numTasks argument controls the number of upserts awaited together; it must be at least 1. Copy failures and cancellation propagate to the caller. Completed deletes and upserts are not rolled back.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.340 0 11/15/2026
11.0.339 74 11/12/2026
11.0.338 68 11/12/2026
11.0.337 80 11/11/2026
11.0.336 71 11/11/2026
11.0.334 68 11/11/2026
11.0.333 86 11/11/2026
11.0.332 80 11/11/2026
11.0.331 84 11/11/2026
11.0.330 124 11/7/2026
11.0.329 115 11/3/2026
11.0.328 95 11/3/2026
11.0.326 112 10/29/2026
11.0.325 100 10/28/2026
11.0.324 104 10/27/2026
11.0.323 105 10/27/2026
11.0.322 99 10/27/2026
11.0.321 102 10/27/2026
11.0.320 97 10/27/2026
11.0.319 100 10/27/2026
Loading failed

Update dependency Soenneker.Cosmos.Suite to 11.0.3602 (#553)