Practical Microservices with Dapr and .NET: A developer’s guide to building cloud-native applications using the event-driven runtime, 2nd Edition
Use the innovative, highly portable event-driven distributed application runtime to simplify building resilient and scalable microservices for cloud and edge applications.
Purchase of the print or Kindle book includes a free eBook in the PDF format.
- Build resilient, stateless, and stateful microservice applications that run on the cloud and edge
- Overcome common issues in distributed systems, such as low latency and scaling, using any language and framework
- Learn how to expose and operate Dapr applications with multiple options
This second edition 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 simplifies development while allowing you to work with multiple languages and platforms. Following a C# sample, you’ll understand how Dapr’s runtime, 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 for building 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. With a focus on deploying the Dapr sample application to an Azure Kubernetes Service cluster and to the Azure Container Apps serverless platform, you’ll see how to expose the Dapr application with NGINX, YARP, and Azure API Management.
By the end of this book, you’ll be able to write microservices easily 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
- Expose API built with Dapr applications via NGINX and Azure API Management
- 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
- Get to grips with Azure Container Apps as you combine Dapr with a serverless platform
Who this book is for
This book is for developers looking to explore and implement microservices architectures in Dapr applications using .NET examples. Whether you are new to microservices or have knowledge of this architectural approach and want to get hands-on experience using Dapr, you’ll find this book useful. Familiarity with .NET will help you to understand the C# samples and code snippets used in the book.
Practical Microservices with Dapr and .NET Foreword Contributors About the author About the reviewers Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Share Your Thoughts Download a free PDF copy of this book Part 1: Introduction to Dapr Chapter 1: Introducing Dapr Technical requirements Understanding Dapr What Dapr is not Exploring Dapr Setting up Dapr Docker Intalling the Dapr CLI Installing .NET Installing VS Code Installing Windows Terminal Installing Dapr in self-hosted mode Installing Dapr on Kubernetes Updating Dapr version Building our first Dapr sample Summary Questions Further reading Chapter 2: Debugging Dapr Solutions Technical requirements Configuring VS Code debug for Dapr Attaching the debugger Examining the debug configuration Debugging a Dapr multi-project solution Creating .NET solutions Launching the configuration Tasks Launching debug sessions individually Launching compound debug sessions Using Tye with Dapr Installing Tye Using Tye Summary Questions Further reading Chapter 3: Microservices Architecture with Dapr Introducing our sample solution Discovering microservices Service Autonomy Automated deployment Bounded context Loose coupling Event-driven architecture Observability Sustainability Adopting microservices patterns Building an e-commerce architecture Bounded contexts An example – sales microservices Building microservices with Dapr Loosely coupled microservices Autonomous microservices Observable microservices Scalable microservices Event-driven microservices Stateless microservices Summary Questions Further reading Part 2: Building Microservices with Dapr Chapter 4: Service-to-Service Invocation Technical requirements Invoking services with Dapr Introducing service-to-service invocation Name resolution Resiliency Service invocation with the .NET SDK Creating a project for the Order service Configuring Dapr in ASP.NET Implementing Dapr with an ASP.NET controller Creating a project for the Reservation service Preparing the debugging configuration Implementing Dapr with an ASP.NET Minimal API Recap Comparing HTTP and gRPC for Dapr gRPC in ASP.NET Creating a gRPC microservice Winning latency with gRPC Summary Questions Further reading Chapter 5: Introducing State Management Technical requirements Managing state in Dapr State, stateless, and stateful State stores in Dapr Transactions Concurrency Consistency Interaction with state stores Resiliency Stateful services in an e-commerce ordering system Stateful reservation-service Handling the Dapr state in ASP.NET Using Azure Cosmos DB as a state store Setting up Azure Cosmos DB Configuring the state store Testing the state store Partitioning with Cosmos DB Wrapping up Summary Chapter 6: Publish and Subscribe Technical requirements Using the pub/sub pattern in Dapr Using Azure Service Bus (ASB) in Dapr Subscribing to a topic Configuring a pub/sub component Publishing to a topic Inspecting the messages Implementing a saga pattern Publishing messages to Dapr Subscribing to a Dapr topic Testing the saga pattern Summary Chapter 7: Resource Bindings Technical requirements Learning how to use Dapr bindings Configuring a cron input binding Testing the cron binding Using Twilio output bindings in Dapr Signing up for a Twilio trial Configuring a Twilio output binding Signaling via the output binding Verifying the notification Ingesting data with the Azure Event Hubs input binding Creating an Azure Event Hubs binding Configuring the input binding Implementing an Azure Event Hubs input binding Producing events Summary Chapter 8: Using Actors Technical requirements Using actors in Dapr Introduction to the virtual actor pattern Configuring a new state store Verifying the configuration Actor concurrency, consistency, and lifetime Placement service Concurrency and consistency Resiliency Lifetime Implementing actors in an e-commerce reservation system Preparing the Actor’s projects Implementing the actor’s model Accessing actors from other Dapr applications Inspecting the actor’s state Summary Part 3: Deploying and Scaling Dapr Solutions Chapter 9: Deploying to Kubernetes Technical requirements Setting up Kubernetes Creating an Azure resource group Creating an AKS cluster Connecting to the AKS cluster Setting up Dapr on Kubernetes Deploying a Dapr application to Kubernetes Building Docker images Pushing Docker images Managing secrets in Kubernetes Deploying applications Exposing Dapr applications to external clients Summary Chapter 10: Exposing Dapr Applications Technical requirements Daprizing ingress controllers Setting up API management on Kubernetes Configuring Dapr policies with API management Summary Chapter 11: Tracing Dapr Applications Technical requirements Observing applications in Dapr Tracing with Zipkin Setting up Zipkin Configuring tracing with Zipkin Enabling tracing in Dapr Investigating with Zipkin Analyzing metrics with Prometheus and Grafana Installing Prometheus Installing Grafana Importing dashboards Summary Chapter 12: Load Testing and Scaling Dapr Technical requirements Bash Python Locust Kubernetes configuration Scaling Dapr on Kubernetes Replicas Autoscale Resource requests and limits Load testing with Locust Load testing Dapr Preparing the data via port-forwarding Testing Locust locally Locust on Azure Container Instances Observing the Horizontal Pod Autoscaler Autoscaling with KEDA Summary Chapter 13: Leveraging Serverless Containers with Dapr Technical requirements Learning about the Azure Container Apps architecture Understanding the importance of Azure Container Apps Setting up Azure Container Apps Deploying Dapr with Azure Container Apps Configuring Dapr components in Azure Container Apps Exposing Azure container apps to external clients Observing Azure container apps Autoscaling Azure Container Apps with KEDA Learning about KEDA autoscalers Applying KEDA to Azure container apps Testing KEDA with container apps Summary Assessments Chapter 1, Introducing Dapr Chapter 2, Debugging Dapr Solutions Chapter 3, Microservices Architecture with Dapr Chapter 4, Service-to-Service Invocation Index Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts Download a free PDF copy of this book
How to download source code?
1. Go to:
2. In the Find a repository… box, search the book title:
Practical Microservices with Dapr and .NET: A developer’s guide to building cloud-native applications using the event-driven runtime, 2nd Edition, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.