GithubHelp home page GithubHelp logo

isabella232 / partitionedrepository Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-samples/partitionedrepository

0.0 0.0 0.0 56 KB

Repository Pattern with Azure Cosmos DB SQL API

License: MIT License

C# 94.47% PowerShell 5.53%

partitionedrepository's Introduction

page_type languages products description urlFragment
sample
csharp
powershell
azure
This project implements a to-do service using ASP.NET Core. It demonstrates how to use the repository pattern with Azure Cosmos DB SQL API.
repository-pattern-with-azure-cosmos-db-sql-api

Repository Pattern with Azure Cosmos DB SQL API

This project implements a sample to-do service using ASP.NET core. It demonstrates how to use the repository pattern with Azure Cosmos DB SQL API. It also demonstrates other best practices for Azure hosted ASP.NET core web applications, such as logging and telemetry with Application Insights and key/secret management via Azure Key Vault.

Repository Pattern

This repository is based on the repository design pattern which isolates data access behind interface abstractions. Connecting to the database and manipulating data storage objects is performed through methods provided by the interface's implementation. Consequently, there is no need to call code to deal with database concerns, such as connections, commands, and readers.

Azure Cosmos DB utilizes partition keys to enable quick look ups in unlimited scaled databases. This repository implements the repository design pattern to support partition keys for Cosmos DB. For details on the execution, please see the code within ./TodoService.Infrastructure/Data.

Benefits of the Partitioned Repository Pattern Implementation

  • Easy reuse of the database access code, because the database communications is centralized in a single place.
  • The business domain can be unit tested independent off the database layer.
  • Integrated partition key support for large scale Cosmos DB projects.

Getting Started

Deploy Azure Resources Using a PowerShell Script

A script for deploying the necessary Cosmos DB resources is located in the AzureResources.DeploymentScript folder. The script will check the existence of a resource group, a Cosmos DB account, a Cosmos DB database, and one or more Cosmos DB collections with partition keys. If the defined resources do not exist they will be created by the script.

The following Parameters are inputs to the script:

  • resourceGroup: where the Cosmos DB instance be created
  • location: where the ResourceGroup and Cosmos DB will be hosted
  • cosmosAccount: Cosmos DB account name
  • cosmosDatabase: Cosmos DB database name
  • cosmosCollections: Cosmos DB collection names separated by comma delimiter i.e col1,col2,col3
  • cosmosCollectionsPartitionKeys: Cosmos DB collection partition key names separated by comma delimiter i.e PK1,PK2,PK3

Prerequisites

Build and Test

The configuration for this solution depends on secrets, either stored locally or in Azure Key Vault. This is to prevent sensitive information from being stored in a public manner. Please see SECRET_MANAGEMENT.md for more information on setting up the secret management system.

Manually Deploying the Solution

The solution can be run locally for development purposes. If you are looking to deploy the solution to an Azure Web App, follow the steps in MANUAL_DEPLOYMENT.md

Resources

partitionedrepository's People

Contributors

johngrud avatar jomalsan avatar microsoftopensource avatar ms-santi avatar msftgits avatar shenglol avatar supernova-eng avatar v-rajagt-zz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.