Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Pragmatic Microservices with C# and Azure
  • Table Of Contents Toc
  • Feedback & Rating feedback
Pragmatic Microservices with C# and Azure

Pragmatic Microservices with C# and Azure

By : Nagel
4.2 (11)
close
close
Pragmatic Microservices with C# and Azure

Pragmatic Microservices with C# and Azure

4.2 (11)
By: Nagel

Overview of this book

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.
Table of Contents (23 chapters)
close
close
Free Chapter
1
Part 1: Creating Microservices with .NET
6
Part 2: Hosting and Deploying
12
Part 3: Troubleshooting and Scaling
16
Part 4: More communication options

What this book covers

Chapter 1, Introduction to .NET Aspire and Microservices, gives you an introduction to .NET Aspire, as well as tools and libraries that can be of great help when creating microservices. You’ll start an initial .NET Aspire project, and we will look at what it consists of and the parts of .NET Aspire you can take advantage of. You’ll see the services that the Codebreaker application (this is the solution we are going to build in all the chapters of the book) is made up of and learn about the services that are used with Microsoft Azure.

Chapter 2, Minimal APIs – Creating REST Services, acts as the kick-off for creating the Codebreaker application. You will learn how to use the ASP.NET Core minimal API technology to efficiently create REST services, use OpenAPI to describe the services, and test the services with HTTP files.

Chapter 3, Writing Data to Relational and NoSQL Databases, uses just the in-memory storage in Chapter 2 and adds database storage using Azure SQL and Azure Cosmos DB, comparing relational to non-relational databases and using EF Core with both variants.

Chapter 4, Creating Libraries for Client Applications, adds client libraries to access the services, with one variant using an HTTP client factory and another making use of Kiota to automatically generate code for the client.

Chapter 5, Containerization of Microservices, dives into all the important concepts of Docker and how to create Docker images from the services created so far. You will learn the concepts of Docker before using the .NET CLI to create Docker images. A .NET native AOT version of a service will be created that allows for creating Docker images without a .NET runtime, just native code.

Chapter 6, Microsoft Azure for Hosting Applications, as Docker images have been created in the previous chapter, will now cover how to publish the application to an Azure Container Apps environment. Before that, important concepts of Azure are covered. Then, Azure resources will be created with the help of the Azure Developer CLI and .NET Aspire.

Chapter 7, Flexible Configurations, dives into the .NET configuration. You’ll understand configuration providers with .NET, learn how configuration applies to the app model of .NET Aspire, add configurations and secrets with Azure Container Apps, and integrate Azure App Configuration and Azure Key Vault. For easier access without the need to store secrets, Azure managed identities are covered here as well.

Chapter 8, CI/CD – Publishing with GitHub Actions, builds on the fact that continuous integration and continuous delivery are important aspects of a microservices solution. This chapter covers how to automatically build and test applications with GitHub actions and how to automatically update solutions running on Microsoft Azure. To support modern deployment patterns, feature flags available with Azure App Configuration are integrated in this chapter.

Chapter 9, Authentication and Authorization with Service and Clients, covers two versions to authenticate and authorize applications and users: integration of Azure Active Directory B2C for the cloud version of the Codebreaker solution and ASP.NET Core identities for the on-premises solution. To avoid dealing with authentication with every service, a gateway using YARP is created.

Chapter 10, All About Testing the Solution, states that no change should break the application and errors should be detected as early as possible. In this chapter, you will learn about creating unit tests, integration tests with .NET Aspire (which makes testing a lot simpler), and using Playwright for end-to-end tests.

Chapter 11, Logging and Monitoring, delves into what is going on in the Codebreaker application. Memory leaks should be detected early. During development, we should look into the details of how the application communicates. This chapter covers efficient high-performance logging, writing custom metrics data, and distributed tracing – including the coverage of OpenTelemetry and how this integrates with .NET Aspire. In this chapter, we use Prometheus and Grafana for the on-premises solution and Azure Application Insights and Azure Log Analytics with the cloud.

Chapter 12, Scaling Services, delves into scaling services, which is one of the important reasons for using a microservices architecture. Using Azure Load Testing, we create a huge load on the main service of the application and find out what the bottlenecks are, decide between scaling up and scaling out, and add caching to increase performance using Redis.

Chapter 13, Real-Time Messaging with SignalR, covers informing clients in real time using SignalR. Using a REST API, a SignalR hub is invoked, passing real-time information about completed games, and the SignalR hub passes on this information to a group of clients. Azure SignalR Service is used to reduce the load from the services.

Chapter 14, gRPC for Binary Communication, increases the performance by changing communication to gRPC with service-to-service communication. You will learn how to create a Protocol Buffers definition, implement services and clients using this binary platform-independent communication, and how .NET service discovery and .NET Aspire can be used with gRPC.

Chapter 15, Asynchronous Communication with Messages and Events, deals with the fact that often answers are not required immediately after the request is sent – message queues and events come into play. Here, Azure message queues, Azure Event Hubs, and Kafka for an on-premises environment come into play to be used.

Chapter 16, Running Applications On-Premises and in the Cloud, discusses what’s needed in a production environment when running on Azure, what the differences between production and development environments are, and how the Codebreaker application fulfills requirements relating to scalability, reliability, and security. Up to this chapter, the application was running either on the local development system or within an Azure Container Apps environment. In this chapter, the application is deployed to Azure Kubernetes Service and can be deployed in a similar way to an on-premises Kubernetes cluster using the Aspir8 tool.

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY