⚙️

Dotnet Architecture Ebooks Reference

.NET Ecosystem Intermediate 4 min read 600 words

.NET Architecture eBooks Reference

This document provides links to official Microsoft .NET Architecture eBooks and key takeaways from each.

Note: These eBooks are freely available from Microsoft. Download the latest versions from the official sources below.

Core Architecture Guides

eBook Official Link Key Topics
Architecting Modern Web Apps with ASP.NET Core and Azure Download Clean Architecture, SOLID, DDD, Testing
.NET Microservices: Architecture for Containerized .NET Applications Download Microservices, Docker, Kubernetes, DDD
Architecting Cloud-Native .NET Apps for Azure Download Cloud-native patterns, resilience, observability
Containerized Docker Application Lifecycle with Microsoft Tools Download Docker, CI/CD, DevOps
DevOps for ASP.NET Core Developers Download Azure DevOps, CI/CD pipelines

Framework-Specific Guides

eBook Official Link Key Topics
Blazor for ASP.NET Web Forms Developers Download Blazor, component model, migration
gRPC for WCF Developers Download gRPC, Protobuf, WCF migration
Serverless apps: Architecture, patterns, and Azure implementation Download Azure Functions, serverless patterns
Porting Existing ASP.NET Apps to .NET Core Download Migration strategies, compatibility
Dapr for .NET Developers Download Dapr, distributed applications

Mobile & Desktop

eBook Official Link Key Topics
.NET MAUI for Mobile Developers Download Cross-platform UI, MAUI patterns
Modernize Desktop Apps with .NET Download WPF/WinForms modernization
Modernize with Azure Containers Download Containerizing existing apps

Key Architecture Concepts Summary

1. Clean Architecture

┌─────────────────────────────────────────┐
│              Presentation               │
│         (Web API, MVC, Blazor)          │
├─────────────────────────────────────────┤
│             Infrastructure              │
│    (EF Core, External Services, I/O)    │
├─────────────────────────────────────────┤
│              Application                │
│      (Use Cases, DTOs, Interfaces)      │
├─────────────────────────────────────────┤
│                 Domain                  │
│      (Entities, Value Objects, DDD)     │
└─────────────────────────────────────────┘

Key Principles:

  • Dependencies point inward (toward the domain)
  • Domain layer has no external dependencies
  • Infrastructure implements interfaces defined in Application layer
  • Presentation layer depends on Application layer

2. Microservices Architecture

When to Use Microservices:

  • Large, complex applications requiring scalability
  • Multiple teams working independently
  • Different parts need different technology stacks
  • Independent deployment requirements

When NOT to Use:

  • Small applications
  • Tight deadlines
  • Team lacks distributed systems experience
  • Simple CRUD operations

Key Patterns:

  • API Gateway: Single entry point for clients
  • Service Discovery: Dynamic service location
  • Circuit Breaker: Fault tolerance
  • Saga Pattern: Distributed transactions
  • Event Sourcing: Audit trail, temporal queries

3. Domain-Driven Design (DDD)

Strategic Patterns:

  • Bounded Context: Clear domain boundaries
  • Ubiquitous Language: Shared vocabulary
  • Context Mapping: Relationships between contexts

Tactical Patterns:

  • Entities: Identity-based objects
  • Value Objects: Immutable, equality by value
  • Aggregates: Consistency boundaries
  • Domain Events: State change notifications
  • Repositories: Collection-like persistence abstraction

4. Cloud-Native Patterns

The Twelve-Factor App:

  1. Codebase - One codebase, many deploys
  2. Dependencies - Explicitly declare and isolate
  3. Config - Store in environment
  4. Backing services - Treat as attached resources
  5. Build, release, run - Strictly separate stages
  6. Processes - Execute as stateless processes
  7. Port binding - Export services via port binding
  8. Concurrency - Scale out via process model
  9. Disposability - Fast startup and graceful shutdown
  10. Dev/prod parity - Keep environments similar
  11. Logs - Treat as event streams
  12. Admin processes - Run as one-off processes

Resilience Patterns:

  • Retry with exponential backoff
  • Circuit breaker
  • Bulkhead isolation
  • Timeout
  • Fallback

5. Containerization Best Practices

Dockerfile Best Practices:

# Use multi-stage builds
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY *.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "MyApp.dll"]

Key Principles:

  • One process per container
  • Immutable containers
  • Layer caching optimization
  • Minimal base images
  • Non-root user execution

6. ASP.NET Core Architecture

Recommended Project Structure:

src/
├── WebApi/              # Presentation layer
├── Application/         # Use cases, DTOs
├── Domain/              # Business logic
├── Infrastructure/      # Data access, external services
└── Tests/
    ├── UnitTests/
    ├── IntegrationTests/
    └── FunctionalTests/

Dependency Injection Lifetimes:

  • Transient: Created each time requested
  • Scoped: Created once per request
  • Singleton: Created once for application lifetime

7. Testing Strategy

Test Pyramid:

        /\
       /  \      E2E Tests (few)
      /────\
     /      \    Integration Tests (some)
    /────────\
   /          \  Unit Tests (many)
  /────────────\

Best Practices:

  • Arrange-Act-Assert pattern
  • One assertion per test (ideally)
  • Test behavior, not implementation
  • Use meaningful test names
  • Mock external dependencies

Quick Reference Commands

Create Clean Architecture Solution

dotnet new sln -n MyApp
dotnet new webapi -n MyApp.WebApi
dotnet new classlib -n MyApp.Application
dotnet new classlib -n MyApp.Domain
dotnet new classlib -n MyApp.Infrastructure

dotnet sln add **/*.csproj

Add Common Packages

# Application layer
dotnet add package MediatR
dotnet add package FluentValidation
dotnet add package AutoMapper

# Infrastructure layer
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Polly  # Resilience

# Testing
dotnet add package xunit
dotnet add package Moq
dotnet add package FluentAssertions

Additional Resources

📚 Related Articles