Welcome to the Cosmos DB in Fabric Samples Repository! 🌟
This repository serves as your comprehensive hub for learning and exploring Cosmos DB in Microsoft Fabric through practical, real-world samples. Whether you're just getting started or looking to implement advanced scenarios, you'll find code samples, datasets, and notebooks to accelerate your development journey.
The Cosmos DB in Fabric Data Explorer - where many of these samples begin
New to Cosmos DB in Fabric? Start here:
- Create a Cosmos DB artifact in your Fabric workspace
- Load sample data using the Data Explorer (click "SampleData" on the Home screen)
- Explore the samples in this repository to learn key concepts and patterns
- 📖 Cosmos DB in Fabric Documentation
- 🎯 Getting Started Guide
- ⚡ Performance Best Practices for Python
- 💡 Design Patterns
- 🔧 Cosmos Python API Reference
| Sample | Description | Prerequisites | Difficulty |
|---|---|---|---|
| Simple Query | Basic CRUD operations and queries using the sample dataset with basic container management | SampleData container | Beginner |
| User Data Functions | Complete collection of Cosmos DB operations using Fabric User Data Functions | SampleData container, User Data Functions enabled | Intermediate |
| Vector Search | AI-powered semantic search using OpenAI embeddings and VectorDistance | SampleVectorData container | Intermediate |
| Price-Review Analytics with Spark | Price-review correlation analysis using Python Spark SQL with interactive visualizations | Cosmos DB with lakehouse shortcuts | Advanced |
| Price-Review Analytics with Power BI | Build Power BI dashboards analyzing price-review correlations using Lakehouse SQL views and DAX measures | Cosmos DB with lakehouse shortcuts, Power BI | Advanced |
| Spark Connector with Scala | Read, query, analyze, and write data using Spark Connector with Scala | Custom Spark environment, JAR libraries | Intermediate |
| Advanced Vector Search | Enterprise-grade vector search with Azure OpenAI deployment, Key Vault integration, and custom embedding models | Azure subscription owner rights, Workspace Identity | Advanced |
| Fraud Detection | Real-time credit card fraud detection using vector search, change feed streaming, and anomaly detection with embeddings | Cosmos DB with vector index, Spark environment, JAR libraries | Advanced |
| Disaster Recovery | Business continuity and disaster recovery procedures using Git integration and OneLake mirroring to restore Cosmos DB artifacts | Git integration, OneLake shortcuts, Spark environment | Advanced |
| Management Operations | Container management, throughput operations, and robust data loading with retry logic | Empty Cosmos DB artifact | Beginner |
| Dataset | Description | Use Case |
|---|---|---|
| fabricSampleData.json | Product catalog with customer reviews | Basic queries and operations |
| fabricSampleDataVectors-ada-002-1536.json | Sample data with Ada-002 embeddings (1536 dimensions) | Vector search scenarios |
| fabricSampleDataVectors-3-large-512.json | Sample data with text-embedding-3-large vectors (512 dimensions) | Advanced vector operations with Azure OpenAI |
- Hybrid Search Samples - Combining vector and traditional search patterns
- Integration Samples - Connecting with other Fabric services
Before running the samples, ensure you have:
- Microsoft Fabric workspace
- Python 3.11+ for notebook samples
- Azure Cosmos SDK (
pip install azure-cosmos) - Sample data loaded in your Cosmos DB container (use Data Explorer)
- Browse the samples using the table of contents above
- Clone or download the repository to your local machine
- Follow the README in each sample folder for specific instructions
- Load the datasets using Cosmos DB Data Explorer in Fabric
- Run the notebooks in your Fabric workspace
- 📖 Check the documentation links above
- 🐛 Report issues using GitHub Issues
- 💬 Ask questions in GitHub Discussions
- 📧 See SUPPORT.md for additional support options
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit Contributor License Agreements.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.