🪐 Simple .NET 8 console utilities to copy or populate data between containers in Azure Cosmos DB.
This repository contains two tools:
- CosmosMover – Copies documents from one container to another within the same Cosmos DB database.
- CosmosPopulator – Used to populate test containers by duplicating data from a source container.
Both tools are built using the Azure Cosmos DB SDK and support working with either the Cosmos DB Emulator or Azure-hosted databases.
CosmosMover/- Console app to move data between containers.CosmosPopulator/- Console app to populate data for testing..gitignore- Ignoresbin/,obj/and other build artifacts.README.md- This documentation file.
- .NET 8 SDK
- Access to an Azure Cosmos DB account or Cosmos DB Emulator.
- Connection strings or keys for your Cosmos DB instance.
Open the Program.cs file in each project and update the following constants:
private const string Endpoint = "https://localhost:8081"; // Or your Azure Cosmos DB endpoint
private const string Key = "<PRIMARY_KEY>"; // Primary key for your Cosmos DB account
private const string DatabaseId = "<DB_NAME>"; // Database name
private const string SourceContainerId = "<SOURCE_CONTAINER_ID>";
private const string TargetContainerId = "<DEST_CONTAINER_ID>";From the root directory of the project you want to run (CosmosMover or CosmosPopulator):
cd CosmosMover
dotnet runor
cd CosmosPopulator
dotnet runThe tool will connect to the specified Cosmos DB database, read all items from the source container, and copy them to the target container. If the target container does not exist, it will be created automatically using the source container’s partition key.
- Both tools use either the Cosmos DB primary key or Azure Active Directory DefaultAzureCredential (if key is empty).
- TLS certificate validation is bypassed for local emulator usage.
- Errors during item insertion are logged but the tool continues processing remaining items.
- These utilities are intended for data migration, testing, or data duplication scenarios.
This repository ignores the following folders and files to avoid committing build artifacts:
bin/
obj/
.vscode/
Feel free to open issues or pull requests. Contributions and feedback are welcome!
This project is licensed under the MIT License.
Created by Dhruvesh Parikh