0%

Use the new, enticing and highly portable event-driven runtime to simplify building resilient and scalable microservices for cloud and edge applications.

Key Features

  • Build resilient, stateless, and stateful microservice applications that run on the cloud and edge
  • Solve common distributed systems such as low latency and scaling using any language and framework
  • Use real-time and proactive monitoring tools to support a reliable and highly available system

Book Description

Over the last decade, there has been a huge shift from heavily coded monolithic applications to finer, self-contained microservices. Dapr is a new, open source project by Microsoft that provides proven techniques and best practices for developing modern applications. It offers platform-agnostic features for running your applications on public cloud, on-premises, and even on edge devices.

This book will help you get to grips with microservice architectures and how to manage application complexities with Dapr in no time. You'll understand how Dapr offers ease of implementation while allowing you to work with multiple languages and platforms. You'll also understand how Dapr's runtime, services, building blocks, and software development kits (SDKs) help you to simplify the creation of resilient and portable microservices. Dapr provides an event-driven runtime that supports the essential features you need to build microservices, including service invocation, state management, and publish/subscribe messaging. You'll explore all of those in addition to various other advanced features with this practical guide to learning Dapr.

By the end of this book, you'll be able to write microservices easily using your choice of language or framework by implementing industry best practices to solve problems related to distributed systems.

What you will learn

  • Use Dapr to create services, invoking them directly and via pub/sub
  • Discover best practices for working with microservice architectures
  • Leverage the actor model to orchestrate data and behavior
  • Use Azure Kubernetes Service to deploy a sample application
  • Monitor Dapr applications using Zipkin, Prometheus, and Grafana
  • Scale and load test Dapr applications on Kubernetes

Who this book is for

This book is for developers looking to explore microservices architectures and implement them in Dapr applications using examples on Microsoft .NET Core. Whether you are new to microservices or have knowledge of this architectural approach and want to get hands-on experience in using Dapr, you'll find this book useful. Familiarity with .NET Core will help you to understand the C# samples and code snippets used in the book.

Table of Contents

  1. Practical Microservices with Dapr and .NET
  2. Why subscribe?
  3. Foreword
  4. Contributors
  5. About the author
  6. About the reviewer
  7. Packt is searching for authors like you
  8. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Reviews
  9. Section 1: Introduction to Dapr
  10. Chapter 1: Introducing Dapr
    1. Technical requirements
    2. An overview of Dapr
    3. What Dapr is not
    4. The architecture of Dapr
    5. Setting up Dapr
    6. Docker
    7. The Dapr CLI
    8. .NET
    9. VS Code
    10. Windows Terminal
    11. Installing self-hosted Dapr
    12. Installing Dapr on Kubernetes
    13. Updating the Dapr version
    14. Building our first Dapr sample
    15. Summary
  11. Chapter 2: Debugging Dapr Solutions
    1. Technical requirements
    2. Configuring Dapr debug in VS Code
    3. Attaching the debugger
    4. Examining the debug configuration
    5. Debugging a Dapr multi-project solution
    6. Creating .NET solutions
    7. Launching the configuration
    8. Tasks
    9. Launching debug sessions individually
    10. Launching compound debug sessions
    11. Using Tye with Dapr
    12. Installing Tye
    13. Using Tye
    14. Summary
  12. Section 2: Building Microservices with Dapr
  13. Chapter 3: Service-to-Service Invocation
    1. Technical requirements
    2. How services work in Dapr
    3. Introducing our sample architecture
    4. Introducing service-to-service invocation
    5. Name resolution
    6. Service invocation with the .NET SDK
    7. Creating a project for the Order service
    8. Configuring Dapr in ASP.NET
    9. Implementing Dapr with an ASP.NET controller
    10. Creating a project for the Reservation service
    11. Preparing the debugging configuration
    12. Implementing Dapr with ASP.NET routing
    13. Recap
    14. HTTP and gRPC for Dapr services
    15. gRPC in ASP.NET
    16. The autonomy of a microservice
    17. Winning latency with gRPC
    18. Summary
  14. Chapter 4: Introducing State Management
    1. Technical requirements
    2. Managing state in Dapr
    3. State, stateless, and stateful
    4. State stores in Dapr
    5. Transactions
    6. Concurrency
    7. Consistency
    8. Interaction with state stores
    9. Stateful services in an e-commerce ordering system
    10. Stateful reservation-service
    11. Handling the Dapr state in ASP.NET controllers
    12. Azure Cosmos DB as a state store
    13. Setting up Azure Cosmos DB
    14. Configuring the state store
    15. Testing the state store
    16. Partitioning with Cosmos DB
    17. Wrapping up
    18. Summary
  15. Chapter 5: Publish and Subscribe
    1. Technical requirements
    2. Using the pub/sub pattern in Dapr
    3. Using Azure Service Bus in Dapr
    4. Subscribing to a topic
    5. Configuring a pub/sub component
    6. Publishing to a topic
    7. Inspecting the messages
    8. Implementing a saga pattern
    9. Publishing messages to Dapr
    10. Subscribing to a Dapr topic
    11. Testing the saga pattern
    12. Summary
  16. Chapter 6: Resource Bindings
    1. Technical requirements
    2. Learning how to use Dapr bindings
    3. Configuring a cron input binding
    4. Testing the cron binding
    5. Using Twilio output bindings in Dapr
    6. Signing up for a Twilio trial
    7. Configuring a Twilio output binding
    8. Signaling via the output binding
    9. Verifying the notification
    10. Ingesting data in C# with the Azure Event Hubs input binding
    11. Creating an Azure Event Hubs binding
    12. Configuring the input binding
    13. Implementing an Azure Event Hubs input binding
    14. Producing events
    15. Summary
  17. Chapter 7: Using Actors
    1. Technical requirements
    2. Using actors in Dapr
    3. Introduction to the actor pattern
    4. Configuring a new state store
    5. Verifying the configuration
    6. Actor lifetime, concurrency, and consistency
    7. Placement service
    8. Concurrency and consistency
    9. Lifetime
    10. Implementing actors in an e-commerce reservation system
    11. Preparing the Actor's projects
    12. Implementing the actor model
    13. Accessing actors from other Dapr applications
    14. Inspecting the actor state
    15. Summary
  18. Section 3: Deploying and Scaling Dapr Solutions
  19. Chapter 8: Deploying to Kubernetes
    1. Technical requirements
    2. Setting up Kubernetes
    3. Creating an Azure resource group
    4. Creating an AKS cluster
    5. Connecting to the AKS cluster
    6. Setting up Dapr on Kubernetes
    7. Deploying a Dapr application to Kubernetes
    8. Building Docker images
    9. Pushing Docker images
    10. Managing secrets in Kubernetes
    11. Deploying applications
    12. Exposing Dapr applications to external clients
    13. Summary
  20. Chapter 9: Tracing Dapr Applications
    1. Technical requirements
    2. Observing applications in Dapr
    3. Tracing with Zipkin
    4. Setting up Zipkin
    5. Configuring tracing with Zipkin
    6. Enabling tracing in Dapr
    7. Investigating with Zipkin
    8. Analyzing metrics with Prometheus and Grafana
    9. Installing Prometheus
    10. Installing Grafana
    11. Importing dashboards
    12. Summary
  21. Chapter 10: Load Testing and Scaling Dapr
    1. Technical requirements
    2. Bash
    3. Python
    4. Locust
    5. Kubernetes configuration
    6. Scaling Dapr on Kubernetes
    7. Replicas
    8. Autoscale
    9. Resource requests and limits
    10. Load testing with Locust
    11. Load testing Dapr
    12. Preparing the data via port-forwarding
    13. Testing Locust locally
    14. Locust on Azure Container Instances
    15. Configuring the Horizontal Pod Autoscaler
    16. Autoscaling with KEDA
    17. Summary
  22. Appendix – Microservices Architecture with Dapr
    1. Discovering microservices
    2. Service
    3. Autonomy
    4. Automated deployment
    5. Bounded context
    6. Loose coupling
    7. Event-driven architecture
    8. Observability
    9. Sustainability
    10. Adopting microservices patterns
    11. Building an e-commerce architecture
    12. Bounded contexts
    13. An example – sales microservices
    14. Building microservices with Dapr
    15. Loosely coupled microservices
    16. Autonomous microservices
    17. Observable microservices
    18. Scalable microservices
    19. Event-driven microservices
    20. Stateless microservices
    21. Summary
  23. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
13.59.82.167