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
<PackageReference Include="Soenneker.Cosmos.Copy" Version="11.0.340" />
<PackageVersion Include="Soenneker.Cosmos.Copy" Version="11.0.340" />
<PackageReference Include="Soenneker.Cosmos.Copy" />
paket add Soenneker.Cosmos.Copy --version 11.0.340
#r "nuget: Soenneker.Cosmos.Copy, 11.0.340"
#:package Soenneker.Cosmos.Copy@11.0.340
#addin nuget:?package=Soenneker.Cosmos.Copy&version=11.0.340
#tool nuget:?package=Soenneker.Cosmos.Copy&version=11.0.340
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Cosmos.Suite (>= 11.0.3602)
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 |
Update dependency Soenneker.Cosmos.Suite to 11.0.3602 (#553)