Skip to content

dhruvesh/CosmosPopulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CosmosMover & CosmosPopulator

🪐 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.


📁 Project Structure

  • CosmosMover/ - Console app to move data between containers.
  • CosmosPopulator/ - Console app to populate data for testing.
  • .gitignore - Ignores bin/, obj/ and other build artifacts.
  • README.md - This documentation file.

⚙️ Prerequisites

  • .NET 8 SDK
  • Access to an Azure Cosmos DB account or Cosmos DB Emulator.
  • Connection strings or keys for your Cosmos DB instance.

🚀 How to Use

Configuration

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>";

Running the Tools

From the root directory of the project you want to run (CosmosMover or CosmosPopulator):

cd CosmosMover
dotnet run

or

cd CosmosPopulator
dotnet run

The 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.


📝 Notes

  • 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.

🗂 .gitignore

This repository ignores the following folders and files to avoid committing build artifacts:

bin/
obj/
.vscode/

📞 Support & Contributions

Feel free to open issues or pull requests. Contributions and feedback are welcome!


📄 License

This project is licensed under the MIT License.


Created by Dhruvesh Parikh

About

Copies data from source cosmos to destination cosmos

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages