Share
Embed
Transcript
23 slides
-
.NET Consultant @ Thinktecture AG Boris Wilhelms ▪ Architecting ☁️-native
solutions ▪ Helps customer building Backend-Things with .NET ▪ Takes care of authentication & authorization / Identity Access Management Solutions ▪ Loves 🐧 [email protected] @boriswilhelms thinktecture.com ASP.NET Core Services fit machen Cloud-Native -
Make ASP.NET Core Services Cloud-Native ready! Is it a lot
of work? 3 ASP.NET Core Services fit machen Cloud-Native -
”… is highly distributed, must operate in a constantly changing
environment, and is itself constantly changing.” Cornelia Davis, Author of Cloud Native Patterns: Designing change-tolerant software Cloud-Native Software 5 ASP.NET Core Services fit machen Cloud-Native -
Availability Scalability Resilience Configurability Observability Cloud-Native Applications Cloud-Native Attributes 6
ASP.NET Core Services fit machen Cloud-Native -
- Observability - Logging - Open Telemetry - Health Checks
- Configurability - Resilience - Reverse Proxy gotchas Cloud-Native ASP.NET Core Services fit machen Topics for today 7 -
- Use ILogger - Log to console - Log as
JSON! Cloud-Native ASP.NET Core Services fit machen Logging 9 -
- Use OpenTelemetry - OpenTelemetry is a collection of tools,
APIs, and SDKs. Use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) to help you analyze your software’s performance and behavior. - ASP.NET Core/.NET emits telemetry data consumeable by OpenTelemetry - Use System.Diagnostics.Activity to create custom traces - Use System.Diagnostics.Meter to create custom metrics Cloud-Native ASP.NET Core Services fit machen Observability 10 -
- Ready vs Live - Ready: - Is the application
ready to serve requests? - Only checked until ready - Live: Is the application still alive? - Checked periodically after ready check - Keep them simple! - Keep “Live” health checks even simpler! - Don’t check for dependencies - This might result in unnecessary restarts of container Cloud-Native ASP.NET Core Services fit machen Health Checks 11 -
ConfigurationBuilder merges the values of different providers together 1. appsettings.json
2. appsettings.{environment}.json (ASPNETCORE_ENVIRONMENT) 3. User Secrets (read once at startup in development) 4. Environment variables (read once at startup) 5. Commandline arguments (read once at startup) Cloud-Native ASP.NET Core Services fit machen How does configuration work in ASP.NET Core? 13 -
- All these providers provide only a snapshot at startup
- Microsoft.Extensions.Configuration.KeyPerFile to the rescue! - Maps a folder of files into the configuration - Filename is the key - Content of the file is the key - Can be used for e.g. ConfigMaps in Kubernetes Cloud-Native ASP.NET Core Services fit machen How does configuration work in ASP.NET Core? 14 -
- Be prepared that a dependency is not there! -
Let the platform handle resilience if possible! - If not: - Some libraries have retries and fallbacks build in (e.g. Azure Storage SDK) - EF Core: “EnableRetryOnFailure” or custom “Execution strategies” - Everything else: Use Polly - Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. Cloud-Native ASP.NET Core Services fit machen Resilience 16 -
Cloud-Native ASP.NET Core Services fit machen How do reverse proxies
work? 18 https://myapp.com/api/products https://myapp.com/api/orders IP: 212.127.12.13 External IP: 112.22.15.43 Internal IP: 10.0.0.1 -
- A reverse proxies - receives the request from the
client - inspects the request to find the proper target - makes the actual http request to the container/service - adds additional headers with data about the client and the called URLs (X-Forwarded-*) - The service - sees the reverse proxy as a client - will be called with a different url/host then it is reachable from the internet - might have different HTTP routes then the reverse proxy - Proxy Route: /api/products - Service Route /products Cloud-Native ASP.NET Core Services fit machen How do reverse proxies work? 20 -
- Let the platform handle things, if possible! - There
is not much to do to be cloud-native ready! - Make infrastructure components as configurable as possible! - Use (defacto-)standards where possible! - Be aware of reverse proxy! They are everywhere! Cloud-Native ASP.NET Core Services fit machen Conclusion 21 -
thinktecture.com/ cloud-30-11-2022 thinktecture.com/ cloud-25-01-2023 Cloud-Native Webinar-Reihe – weitere Termine thinktecture.com/
cloud-14-12-2022 thinktecture.com/ cloud-11-01-2023 Alle Webinare unserer Cloud-Native-Reihe finden Sie hier: thinktecture.com/cloud-native-webinare/ 03. November 2022 – 25. Januar 2023 ASP.NET Core Services fit machen Cloud-Native 22 -
https://www.thinktecture.com/ueber-uns/karriere/ Dankeschön! Demos aus der Session: https://github.com/thinktecture-labs/aspnetcore- cloudnative Boris Wilhelms
https://thinktecture.com/boris-wilhelms 23