https://github.com/azurecosmosdb/cosmicworks
How to model and partition data for Cosmos DB starting with the Adventure Works database.
https://github.com/azurecosmosdb/cosmicworks
adventureworks azure-cosmos-db cosmos-db sample
Last synced: 25 days ago
JSON representation
How to model and partition data for Cosmos DB starting with the Adventure Works database.
- Host: GitHub
- URL: https://github.com/azurecosmosdb/cosmicworks
- Owner: AzureCosmosDB
- License: mit
- Created: 2019-10-30T22:07:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-02-18T17:56:03.000Z (2 months ago)
- Last Synced: 2025-03-31T16:13:55.544Z (about 1 month ago)
- Topics: adventureworks, azure-cosmos-db, cosmos-db, sample
- Language: C#
- Homepage:
- Size: 58.2 MB
- Stars: 83
- Watchers: 68
- Forks: 29
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: change-feed-categories/Program.cs
- License: LICENSE.md
Awesome Lists containing this project
README
# CosmicWorks
How to migrate a relational data model to Azure Cosmos DB, a distributed, horizontally scalable, NoSQL database.
This sample demonstrates how to migrate a relational database to a distributed, NoSQL database like Azure Cosmos DB.
This repo contains a Powerpoint presentation and a Visual Studio solution that represents the demos for this presentation with three projects in it:* **modeling-demos**: This contains the main app that shows the evolution of the data models from v1 to v4
* **change-feed-categories**: This project uses change feed processor to monitor the product categories container for changes and then propagates those to the products container.
* **models**: This project contains all of the POCO classes used in both projects.
* **cosmos-management**: This project contains the Cosmos DB management SDK classes used to create the databases and containers.
## Steps to setup
[](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fazurecosmosdb%2Fcosmicworks%2Fmaster%2Fazuredeploy.json)
1. Clone this repository to your local machine.
1. Click the Deploy to Azure button above. This will provision a new Cosmos DB account in a single region.
1. When the deployment is complete, click on the Outputs tab in the custom deployment blade. Copy the `uri` and `key` values and save locally.
1. Open the Cosmic Works solution file.
1. Add the `uri` and `key` information to the appSettings.json file for both the 'change-feed-categories' and 'modeling-demos' VS Project files or right click each project, select 'Manage User Secrets' and enter the same key and values as key-value pairs there.
1. Right click the 'modeling-demos' project and set as start up. Then press F5 to start it.
1. On the main menu, press 'k' to create the database and container resources. (This is a serverless account so there is no cost to create these resources.)
1. On the main menu, press 'l' to load data. (Note, this can take some time when run locally over low bandwidth connections. Best performance is running in a GitHub Codespace or on a VM in the same region the Cosmos account was provisioned in.)
1. After the data is loaded, return to Visual Studio, right click the 'change-feed-categories' project and select, Debug, Start a new instance.
1. In the modeling-demos project, put breakpoints for any of the functions you want to step through, then press the corresponding menu item key to execute.> [!IMPORTANT]
> This runs in a serverless Cosmos DB account so you will not incur RU charges when not running. But you will pay for storage.
If you do not plan to run this sample for a long time, to minimize cost, it is recommended to run the 'Delete databases and containers' item from the main menu. This will delete the databases and containers and just leave an empty Cosmos account which has no cost.
You can then start the sample again and run 'k' and 'l' menu items to rehydrate the account.## Source data
Below is the source data for the 4 versions of the Cosmos DB databases as it progresses through its evolution from a relational database to a highly scalable NoSQL database.
* [Cosmic Works version 1](https://github.com/AzureCosmosDB/CosmicWorks/tree/master/data/database-v1)
* [Cosmic Works version 2](https://github.com/AzureCosmosDB/CosmicWorks/tree/master/data/database-v2)
* [Cosmic Works version 3](https://github.com/AzureCosmosDB/CosmicWorks/tree/master/data/database-v3)
* [Cosmic Works version 4](https://github.com/AzureCosmosDB/CosmicWorks/tree/master/data/database-v4)
You can also [download a bak file](https://github.com/AzureCosmosDB/CosmicWorks/tree/master/data/adventure-works-2017) for the original Adventure Works 2017 database this session and app is built upon.