Skip to content
Sample repository pattern for Azure Table Storage
C#
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ClassLibrary1.Tests refactor{ Feb 21, 2020
ClassLibrary1 updated docs Feb 25, 2020
FunctionApp1.Tests refactor{ Feb 21, 2020
FunctionApp1
.gitignore initial commit Feb 10, 2020
MJR040.sln
README.md updated docs Feb 25, 2020

README.md

Introduction

This is an example of leveraging the Microsoft.Azure.Cosmos.Table NuGet package in a repository pattern.

Prerequisites

The following prerequisites are required:

Projects

ClassLibrary1.csproj

This project contains the standard interfaces and abstract classed to support how Azure Table Storage should be implemente for reading and writing.

The Entity classes are for root entities, e.g. ToDo, while the ChildEntity classes are for children of root entities, e.g. ToDoComment.

From a code perspective, the main difference between Entity and ChildEntity is that ChildEntity is open to having a ParentId property which is required for most calls using the ChildEntityDataStore.

ClassLibrary1.Tests.csproj

Contains the tests for the ClassLibrary1 project.

The tests cover valid configuration options.

FunctionApp1.csproj

This project contains the concrete implementations of the ToDo and ToDoComment entities and data stores - the repositories in a repository design pattern - that are persisted to Azure Table Storage.

It also contains Azure Functions, and supporting classes, for CRUD operations: create, retrieve, update and delete.

FunctionApp1.Tests.csproj

Contains the tests for the FunctionApp1 project.

The tests cover reading and writing data use the EntityDataStore classes.

Currently the tests are setup to run locally using the Azure Storage Emulator.

{
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  "AzureTableStorageOptions:ConnectionString": "UseDevelopmentStorage=true"
}

To use storage in Azure, update the AzureTableStorageOptions:ConnectionString property with your Primary or Secondary connection strings.

Related Articles

You can’t perform that action at this time.