This document discusses strategies for taking .NET Core container solutions from development to production quickly and reliably. It demonstrates using containerization with Docker to achieve speedy development cycles through practices like trunk-based development in isolated containers. The document also covers important aspects for production such as monitoring, logging, security and treating infrastructure as code. Automating the entire pipeline from code to production deployment in minutes is the overall goal.
30. 30
Container cluster
Examples of external resources
Solution composed of
multiple containers
Different compositions
per environment
Web
Frontend
Web API Backend service
40. 41
API v1.0*
Version with new
functionality
behind feature
toggle
Works well with CI/CD
Traffic management
API v1.0
Original version
Traffic manager
Directs between versions
43. 44
Resiliency: design for failure
Determine your strategy for resiliency
Focus on dependencies outside of your own container
Cloud and containers:
Transient errors
are a fact,
not a possibility
47. 48
Message templates
Log providers supporting semantic logging
// Placeholders in template become queryable custom data
logger.LogInformation("Searching with {SearchLimit} results.", limit);
48. 49
Get your log levels right
Register logging providers (sinks)
Log Levels
5 – Critical
4 – Error
3 – Warning
2 – Information
1 – Debug
0 – Trace
loggerFactory.AddApplicationInsights(…);
loggerFactory.AddAzureWebAppDiagnostics(…)
loggerFactory.AddEventSourceLogger();
Tips and tweaks
High performance logging with LogMessage.Define
Use scopes for bundling logs messages
Apply filters per category prefix to reduce noise
49. 50
Leverage existing resources
Appropriate filters
for each sink
Metrics and monitoring
e.g. Application Insights
AppMetrics
Log indexers
e.g. OMS Log Analytics,
Splunk, ELK stack
Application logs and traces
File or blob based logs
ETW, IntelliTrace,
Azure App Service logging
Your Web API
Instrumented with
log output
51. 52
Specific endpoints to query
status of Web API
Middleware exposes health details
Combine with monitoring solution to alert ops
Microsoft.AspNetCore.
Diagnostics.HealthChecks
Version 2.2.0
App.Metrics.AspNetCore.Health
Version 2.0.0
services
.AddHealthChecks()
.AddPrometheusGatewayPublisher("http://pushgateway:9091/metrics", "pushgateway")
.AddCheck<CertificateHealthCheck>("ssl")
.AddDbContextCheck<LeaderboardContext>("Database");