Practical Microservices with Dapr and .NET
eBook - ePub

Practical Microservices with Dapr and .NET

A developer's guide to build cloud native applications using the Dapr event-driven runtime

  1. 262 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Practical Microservices with Dapr and .NET

A developer's guide to build cloud native applications using the Dapr event-driven runtime

Book details
Book preview
Table of contents
Citations

About This Book

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.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Practical Microservices with Dapr and .NET by Davide Bedin in PDF and/or ePUB format, as well as other popular books in Computer Science & Systems Architecture. We have over one million books available in our catalogue for you to explore.

Information

Year
2020
ISBN
9781800564268
Edition
1

Section 1: Introduction to Dapr

This first part of the book will give you a starting point for Dapr, with an overview of what it is and its main features and components.
This section has the following chapters:
  • Chapter 1, Introducing Dapr
  • Chapter 2, Debugging Dapr Solutions

Chapter 1: Introducing Dapr

This chapter will introduce you to the Distributed Application Runtime (Dapr) project to teach you the core concepts of its architecture and prepare you to develop with Dapr.
Dapr accelerates the development of new cloud-native applications and simplifies the adoption of a microservice architecture.
In this chapter, we are going to cover the following main topics:
  • An overview of Dapr
  • The architecture of Dapr
  • Setting up Dapr
  • Building our first Dapr sample
At this stage, learning these topics is important with regard to obtaining a solid foundation on Dapr internals and understanding its approach to microservice architectures. These basic concepts will guide our learning throughout the rest of this book.
Our first steps into the project will start with exploring Dapr and understanding how it works.

Technical requirements

The code for this sample can be found in GitHub at https://github.com/PacktPublishing/Practical-Microservices-with-Dapr-and-.NET/tree/main/chapter01.
In this chapter, the working area for scripts and code is expected to be <repository path>\chapter01\. In my local environment, it is C:\Repos\dapr-samples\chapter01.
Please refer to the Setting up Dapr section for a complete guide to the tools needed to develop with Dapr and work with the samples.

An overview of Dapr

Dapr is an event-driven, portable runtime created by Microsoft with an open source approach and, at the time of writing this book, is still in active development.
Being event-driven, which is emphasized in the definition of Dapr, plays an important role in microservices as an application can be designed to efficiently react to events from external systems or other parts of the solution, and to produce events as well, in order to inform other services of new facts or to continue processing elsewhere or at a later stage.
Dapr is portable, as it can run locally on your development machine in self-hosted mode; it can also be deployed to the edge, or it can run on Kubernetes.
The following diagram shows the many building blocks of a Dapr architecture:
Figure 1.1 – Dapr architecture
Figure 1.1 – Dapr architecture
Portability does also extend beyond the hosting environment—while Dapr is an initiative that was started by Microsoft, it can also run on Kubernetes on-premises or in the cloud, with Microsoft Azure, Amazon Web Services (AWS), Google Cloud Platform (GCP), or any other cloud vendor.
Dapr has been built on the experience gained by Microsoft in developing hyperscale cloud-native applications. It has been inspired by the design of Orleans and Service Fabric, which in turn enables many Microsoft Azure cloud services to operate resiliently and at a large scale.
Dapr offers developers an approach to design the tools to build and the runtime to operate applications, based on a microservice architecture style.
Microservices offer a vast array of benefits balanced by increased complexities in team and product management, usually with a significant burden on the developer and the team in order to get started.
What if you could leverage a runtime such as Dapr to help you get through the common patterns you will likely need to adopt, and thus ease your operations?
This diagram shows the two Dapr hosting modes:
Figure 1.2 – Dapr sidecar
Figure 1.2 – Dapr sidecar
As depicted in Figure 1.2, the Dapr runtime operates in sidecar processes, lifting most of the complexity from the application to a separate environment, greatly simplifying development and operations as well. These sidecar processes are run locally in your development environment or as containers in a Pod on Kubernetes.
From an application perspective, Dapr is an application programming interface (API) that can be directly reached via HyperText Transfer Protocol (HTTP) or gRPC Remote Procedure Call (gRPC) calls or, even more simply, via any of the software development kits (SDKs) available. At the time of writing this book, these SDKs are .NET, Java, Go, Python, C++, JavaScript, and Rust.
As we will experience later, it is not necessary to adopt the Dapr SDK in your application: a call to a Dapr service can be as simple as an HTTP call to an endpoint such as http://localhost:3500/v1.0/invoke/<app-id>/method/<method name>. Nevertheless, using the SDK does provide many benefits if you are writing a Dapr service or leveraging the Dapr actor model.

What Dapr is not

While I hope the overview of Dapr has informed and intrigued you enough to spend time on this book, when I have the chance to talk about Dapr, I often find myself in need of clarifying what Dapr is not. This makes it easier to eliminate any misconceptions we may have about what Dapr does, as follows:
  • Dapr's goal is not to force the develo...

Table of contents

  1. Practical Microservices with Dapr and .NET
  2. Why subscribe?
  3. Preface
  4. Section 1: Introduction to Dapr
  5. Chapter 1: Introducing Dapr
  6. Chapter 2: Debugging Dapr Solutions
  7. Section 2: Building Microservices with Dapr
  8. Chapter 3: Service-to-Service Invocation
  9. Chapter 4: Introducing State Management
  10. Chapter 5: Publish and Subscribe
  11. Chapter 6: Resource Bindings
  12. Chapter 7: Using Actors
  13. Section 3: Deploying and Scaling Dapr Solutions
  14. Chapter 8: Deploying to Kubernetes
  15. Chapter 9: Tracing Dapr Applications
  16. Chapter 10: Load Testing and Scaling Dapr
  17. Appendix – Microservices Architecture with Dapr
  18. Other Books You May Enjoy