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.