ebook img

Practical Microservices with Dapr and .NET: A developer's guide to building cloud-native applications using the event-driven runtime, 2nd Edition PDF

312 Pages·2022·7.05 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Practical Microservices with Dapr and .NET: A developer's guide to building cloud-native applications using the event-driven runtime, 2nd Edition

Practical Microservices with Dapr and .NET A developer's guide to building cloud-native applications using the event-driven runtime Davide Bedin BIRMINGHAM—MUMBAI Practical Microservices with Dapr and .NET Copyright © 2022 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Group Product Manager: Gebin George Publishing Product Manager: Sathyanarayanan Ellapulli Senior Editor: Rounak Kulkarni Technical Editor: Pradeep Sahu Copy Editor: Safis Editing Project Coordinator: Manisha Singh Proofreader: Safis Editing Indexer: Sejal Dsilva Production Designer: Ponraj Dhandapani Developer Relations Marketing Executive: Sonakshi Bubbar First published: June 2019 Second edition: November 2022 Production reference: 1141022 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-80324-812-7 www.packt.com To my wife Silvia, and my sons, Abramo and Elia: nothing would have been possible without you. – Davide Bedin Foreword It’s been three years since November 2019, when Microsoft launched the initial public release of Dapr, a distributed application runtime, and two years since the first edition of this book was published. Dapr started as an incubation called Actions in the Azure Office of the CTO in early 2019. Its goal was to simplify the development of distributed microservice-based cloud-native applications. I can say with pride that Dapr is now widely seen as doing just that. It’s a Cloud Native Computing Foundation (CNCF) incubating project and is one of the very few that skipped sandbox stage when accepted to the CNCF. Dapr has over 1000 contributors, over 100 components, is in production at dozens of enterprises, and has even been integrated into cloud-native compute services by multiple cloud providers. Dapr’s novel innovation is that it implements a growing collection of abstract APIs, called building blocks, that it makes available to applications via a side-car HTTP or gRPC interface. The building blocks include service invocation for microservices to exchange synchronous requests, pub/sub for asynchronous message delivery, state store for saving data, input/output for integrating with external services, secret management, configuration management, and more. Because applications use Dapr APIs and not service APIs directly, you can plug in a component (which is an implementation of a building block) without changing application code. Using a building block makes code portable across different environments with respect to the building block’s functionality, including across multiple clouds. If you want to deploy code to Azure, for example, you can plug in the Event Hubs component into the pub/sub building block, then swap it out to Kinesis when you deploy the application to AWS. Not only that, but Dapr manages authentication, retries, throttling, and circuit breaking, and has built-in monitoring for all its APIs, insulating developers from having to worry about those mundane yet critical programming practices. Unlike other distributed programming models, Dapr’s side-car architecture enables code written in any language and the use of any framework to leverage Dapr’s services. Furthermore, applications can use building blocks a la carte, or choose to use them fully. That makes Dapr incrementally adoptable so that you can daprize your existing projects at your own pace. In summary, Dapr is becoming the de facto cloud OS API surface. In the two years since the first edition of this book was published, the book has helped thousands of .NET developers to jump start their use of Dapr. Since then, Dapr’s capabilities have grown, and so has the number of building blocks. While nothing prevents you from using Dapr APIs directly via HTTP or gRPC, the .NET SDK has kept pace to make idiomatically native .NET interfaces. Whether you’re new to Dapr, or a Dapr expert and owner of the first edition of this book, this update is for you. There’s no faster way for you to learn not just Dapr, but the tips and tricks that will enable you to focus on your .NET application’s business logic and let Dapr, your cloud-native butler, take care of the rest. Mark Russinovich Azure CTO and Technical Fellow Microsoft Contributors About the author Davide Bedin is a cloud-native architecture enthusiast, with strong and relevant experience with cloud platforms. As the CTO of an ISV, Davide led its transformation process with the objective of creating new solutions based on the Microsoft Azure cloud. Davide particularly focused on the evolution of distributed computing to service-oriented architectures and, ultimately, microservices, spending most of his developer career creating web services. As a senior cloud solution architect at Microsoft, Davide is responsible for the guidance and support of enterprise customers in embracing the cloud paradigm, a key enabler of their digital transformation; lately, he has also been playing with Dapr. I thank Francesco Lana, Andrea Tosato, and Marco Zamana for their advice in creating the second edition of this book. Also, I have been blessed with the wisdom of many great teachers during my career: there are too many to list them all here – you all know who you are. About the reviewers Andrea Tosato is a full-stack software engineer and architect on .NET applications. Andrea successfully develops .NET applications in various industries, sometimes facing complex technological challenges. He deals with desktop, web, and mobile development but with the arrival of the Azure cloud, it became his passion. In 2017, he co-founded Cloudgen Verona, a .NET community based in Verona, Italy, with his friend Marco Zamana. In 2019, he was named Microsoft MVP for the first time in the Azure category. Andrea graduated from the University of Pavia with a degree in computer engineering in 2008 and successfully completed his master’s degree, also in computer engineering, from Modena in 2011. Andrea was born in 1986 in Verona, Italy, where he currently works as a remote worker. You can find Andrea on Twitter. Marco Zamana lives in Verona in the magnificent hills of Valpolicella. He has a background as a software developer and solution architect. He was Microsoft’s Most Valuable Professional for 3 years in the artificial intelligence category. He currently works as a cloud solution architect engineering at Microsoft. He is the co-founder of Cloudgen Verona, a community that wants to discuss topics related to the cloud and, above all, Azure. Table of Contents Preface xv Part 1: Introduction to Dapr 1 Introducing Dapr 3 Technical requirements 3 Installing VS Code 11 Understanding Dapr 4 Installing Windows Terminal 11 Installing Dapr in self-hosted mode 12 What Dapr is not 6 Installing Dapr on Kubernetes 13 Exploring Dapr 7 Updating Dapr version 13 Setting up Dapr 9 Building our first Dapr sample 14 Docker 10 Summary 18 Intalling the Dapr CLI 10 Questions 19 Installing .NET 10 Further reading 19 2 Debugging Dapr Solutions 21 Technical requirements 21 Creating .NET solutions 29 Configuring VS Code debug for Dapr 22 Launching the configuration 30 Tasks 31 Attaching the debugger 22 Launching debug sessions individually 32 Examining the debug configuration 24 Launching compound debug sessions 33 Debugging a Dapr multi-project Using Tye with Dapr 35 solution 28 Installing Tye 35

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.