chapter two

2 Managing Infrastructure Components With Containers and Integrations

 

This chapter covers

  • The fundamentals of Docker containers.
  • Integrating a Keycloak Docker container with .NET Aspire to enable SSO security.
  • Understanding .NET Aspire integrations and their benefits over raw Docker containers.
  • Adding a pre-built .NET Aspire integration for Redis to an application.
  • Building a custom .NET Aspire integration library from scratch.

In a real-life enterprise-grade application, services need to be connected to various infrastructure components, such as databases, message brokers, etc.. In this chapter, we will discuss two ways infrastructure components can be wired up in a .NET Aspire application:

  1. By using Docker containers
  2. Via the .NET Aspire integration libraries

Most enterprise-grade systems require security, and the e-commerce application we are building is no exception. In fact, security is very important in these kinds of applications. You absolutely don’t want anyone to steal your credit card data or make purchases on your behalf! This is why, in this chapter, we will focus on security and build a system that will allow our users to be able to register, log in, and gain the necessary permissions to access appropriate areas of our app.

2.1 Docker containers overview

2.2 Keycloak overview

2.3 Initial setup

2.4 Adding a Keycloak container to .NET Aspire host

2.4.1 Configuring web front-end app

2.4.2 Configuring API service

2.4.3 Other service types .NET Aspire can host

2.5 How .NET Aspire integration libraries differ from containers

2.6 Configuring .NET Aspire integrations on the host

2.6.1 Connecting to an integration from a hosted service

2.6.2 Viewing integrations in the dashboard

2.7 Building a .NET Aspire integration library

2.7.1 Building an integration component

2.7.2 Launching a custom integration from Aspire Host

2.8 Summary