35,99 €
Pragmatic Microservices with C# and Azure introduces .NET Aspire for microservices, focusing on defining an app model, utilizing service discovery, and integrating with Azure's native cloud services. Written by a Microsoft MVP and seasoned software architect with over two decades of experience in .NET, this book will help you get to grips with robust service development using .NET features like minimal APIs, gRPC, and SignalR for real-time communication.
Aside from covering essential aspects of DevOps, including testing methodologies such as unit, integration, and load testing, you’ll also explore logging and monitoring including OpenTelemetry using tools like Azure Log Analytics, Application Insights, Prometheus, and Grafana. You'll learn about asynchronous communication leveraging queues and events through Azure Event Hub and Apache.
Throughout the book, theoretical aspects will be complemented by practical skills gained from building and deploying a fully functional microservices-based application. By the end, you’ll possess a deep understanding of microservices architecture, hands-on experience with various .NET technologies and Azure services, and the ability to design, build, deploy, and manage microservices applications effectively in both on-premises and cloud environments.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 569
Veröffentlichungsjahr: 2024
Pragmatic Microservices with C# and Azure
Build, deploy, and scale microservices efficiently to meet modern software demands
Christian Nagel
Copyright © 2024 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.
Publishing Product Manager: Kunal Sawant
Book Project Manager: Prajakta Naik
Senior Editor: Rounak Kulkarni
Technical Editor: Jubit Pincy
Copy Editor: Safis Editing
Proofreader: Rounak Kulkarni
Indexer: Hemangini Bari
Production Designer: Alishon Mendonca
Senior Developer Relations Marketing Executive: Shrinidhi Monaharan
Business Development Executive: Samriddhi Murarka
First published: May 2024
Production reference: 1240524
Published by Packt Publishing Ltd.
Grosvenor House
11 St Paul’s Square
Birmingham
B3 1RB, UK
ISBN 978-1-83508-829-6
www.packtpub.com
To my mother, Margarete Nagel, and the memory of my father, Ernst, for always supporting me when help was needed. To my wife, Angela, and my children, Stephanie, Matthias, and Katharina – I love you all! Thank you for being here!
– Christian Nagel
Christian Nagel is a Microsoft MVP for Microsoft Azure and Development Technologies, software architect, and veteran developer who has been building solutions with .NET technologies since 2000 and working with UNIX and OpenVMS since before that. He has authored many acclaimed .NET books, and speaks at international conferences such as TechEd, TechDays, Thrive, and BASTA! Christian is a Microsoft Certified Trainer, DevOps Engineer Expert, and Azure Developer Associate. He’s the founder of CN innovation, a company offering training, consulting, and development. Even after many years in software development, Christian still loves learning, using new technologies, and teaching others how to use them. Using his profound knowledge of Microsoft technologies, he has written various books. Contact him via his website at https://www.cninnovation.com, and follow his posts on X (formerly Twitter) at @christiannagel.
This book was a great journey that started before the first public preview of .NET Aspire. I would like to thank the .NET Aspire team for their fast fixes and their support; special thanks to David Fowler with whom I had interesting discussions. I would like to thank my reviewers: István Novák, who has already reviewed several of my books and always helps remind me when I miss something that helps you – the reader – to better follow the content, and Brady Gaster, for his great inspirations and insights on Microsoft technologies, and, if he can’t help, he always has contacts who can. I also thank Sebastian Szvetecz, who is now part of CN innovation and has great inputs to the Codebreaker repository. Last but not least, I thank the team at Packt for making this book a reality.
Brady Gaster works on the .NET tools team, where he collaborates with product teams such as ASP.NET, Azure Container Apps, Functions, App Service, and the Azure SDK to help .NET developers using ASP.NET, SignalR, Orleans, and .NET Aspire have a great experience building apps with .NET and Azure. When Brady’s not learning with (or from) his two sons or hacking on demos and samples, he’s probably in his home music studio making music with various analog synthesizers and drum machines, burning calories by bouncing up and down as he spins drum and bass or dubstep, or finding ways to combine some or all of the above into a new mashup with a cacophony of cables.
Istvan Novak is a freelance technology consultant and commonsense coach. In the last 30 years, he participated in over 50 enterprise software development projects.
In 2002, he co-authored the first Hungarian book on .NET development. In 2007, he was awarded the Microsoft MVP title, holding it for 16 years. In 2011, he became a Microsoft Regional Director for six years.
Istvan holds a master’s degree from the Technical University of Budapest, Hungary, and a doctoral degree in software technology. He is a passionate scuba diver. You may have a good chance of meeting him underwater in the Red Sea in any season of the year.
Part 1 introduces the fundamental functionality of a microservices application. Before delving into the development of the Codebreaker application, you will explore .NET Aspire - a new cloud-ready stack for service construction. This section covers the technology’s offerings, essential features, an introduction to Microsoft Azure, and an overview of the components comprising the Codebreaker application. Subsequently, you will engage in coding using ASP.NET Core minimal APIs, crafting code for data interaction with both relational and NoSQL databases through Entity Framework (EF) Core, utilizing Azure Cosmos DB and SQL Server, and generating client libraries to access the REST service. One approach involves leveraging the HTTP client factory, while the other employs Microsoft Kioata.
Each chapter in this section provides a functional application that evolves with each subsequent chapter, enhancing the learning experience.
This part has the following chapters:
Chapter 1, Introduction to .NET Aspire and MicroservicesChapter 2, Minimal APIs – Creating REST ServicesChapter 3, Writing Data to Relational and NoSQL DatabasesChapter 4, Creating Libraries for Client ApplicationsSince .NET 6, minimal APIs are the new way to create REST APIs. With later .NET versions, more and more enhancements have been made available, which makes them the preferred way to create REST services with .NET.
In this chapter, you’ll learn how to create a data representation of the game with model types, use these types in a service to implement the game functionality, create a minimal API project to create games, update games by setting game moves, and return information about games.
You’ll implement functionality to offer an OpenAPI description for developers accessing the service to get information about the service, and an easy way to create a client application.
In this chapter, you’ll be exploring these topics:
Creating models for the gameImplementing an in-memory game repositoryImplementing the REST service of the game using minimal APIsUsing OpenAPI to describe the serviceTesting the service using HTTP filesEnabling .NET AspireBy the end of this chapter, you’ll have a running service implementing the Codebreaker Games API with an in-memory games store, accessible using HTTP requests.
The code for this chapter can be found in the following GitHub repository: https://github.com/PacktPublishing/Pragmatic-Microservices-with-CSharp-and-Azure. The ch02 source code folder contains the code samples for this chapter. You’ll find the code for the following:
Codebreaker.GamesAPIs – The Web API projectCodebreaker.GamesAPIs.Models – A library for the data modelsCodebreaker.GameAPIs.Analyzers – A library containing game move analyzers for the gameCodebreaker.GamesAPIs.Analyzers.Tests – Unit tests for the game move analyzersCodebreaker.AppHost – The host project for .NET AspireCodebreaker.ServiceDefaults – A library used by the .NET Aspire configurationNote
You don’t implement the game move analyzers of the game in this chapter. The Analyzers project is just for reference purposes, but you can simply use a NuGet package for the analyzers (CNinnovation.Codebreaker.Analyzers) that has been made available for you to build the service.
For the installation of Visual Studio, Visual Studio Code, and .NET Aspire, check the README file for this chapter in the repository.
Before