Member-only story
Clean Architecture — Audit Log Using Partitioned Repository Pattern With Cosmos DB
Discussing how to automatically audit changes using Partitioned Repository Pattern with Azure Cosmos DB, ASP.NET Core and Clean Architecture, and partition key design strategy.

UPDATE April 10, 2022: all projects in the GitHub repo have been upgraded to .NET 5.
Why Audit Log?
- Regulation purpose. For example, sensitive data like personal identifiable and patient health data, is regulated by the HIPPA law in US and the PIPEDA law in Canada. Access to data is required to be audited.
- Versioning. Audit log allows you to see the entire history of your data and gives you the ability to restore your data to any point of save point, which is an amazing feature and is seen in more and more applications.
- Many other use cases. If you are reading this article, you probably already have one!
A most common example is Google docs and Microsoft docs that allow you to see full edit history. If you write Medium stories like I do, Medium allows you to see your full story edit history and restore your story to any save point. In the screenshots below, you will see that every…