$30 off During Our Annual Pro Sale. View Details »

Cloud-Native_-_ASPNETCore.pdf

Boris Wilhelms
November 17, 2022
250

 Cloud-Native_-_ASPNETCore.pdf

Boris Wilhelms

November 17, 2022
Tweet

Transcript

  1. Cloud-Native Webinar-Reihe
    Cloud-Native: ASP.NET Core Services fit machen

    View Slide

  2. .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

    View Slide

  3. Make ASP.NET Core Services
    Cloud-Native ready!
    Is it a lot of work?
    3
    ASP.NET Core Services fit machen
    Cloud-Native

    View Slide

  4. No!
    4
    ASP.NET Core Services fit machen
    Cloud-Native

    View Slide

  5. ”… 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

    View Slide

  6. Availability
    Scalability
    Resilience
    Configurability
    Observability
    Cloud-Native
    Applications
    Cloud-Native Attributes
    6
    ASP.NET Core Services fit machen
    Cloud-Native

    View Slide

  7. - Observability
    - Logging
    - Open Telemetry
    - Health Checks
    - Configurability
    - Resilience
    - Reverse Proxy gotchas
    Cloud-Native
    ASP.NET Core Services fit machen
    Topics for today
    7

    View Slide

  8. Observability
    8
    ASP.NET Core Services fit machen
    Cloud-Native

    View Slide

  9. - Use ILogger
    - Log to console
    - Log as JSON!
    Cloud-Native
    ASP.NET Core Services fit machen
    Logging
    9

    View Slide

  10. - 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

    View Slide

  11. - 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

    View Slide

  12. Configurability
    12
    ASP.NET Core Services fit machen
    Cloud-Native

    View Slide

  13. 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

    View Slide

  14. - 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

    View Slide

  15. Resilience
    15
    ASP.NET Core Services fit machen
    Cloud-Native

    View Slide

  16. - 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

    View Slide

  17. Reverse Proxy gotchas
    17
    ASP.NET Core Services fit machen
    Cloud-Native

    View Slide

  18. 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

    View Slide

  19. Reverse Proxy gotchas
    19
    ASP.NET Core Services fit machen
    Cloud-Native

    View Slide

  20. - 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

    View Slide

  21. - 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

    View Slide

  22. 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

    View Slide

  23. 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

    View Slide