This week, my second Pluralsight course, “Using Configuration and Options in .NET Core and ASP.NET Core Apps” was released. This new course dives deeply into the configuration and options extension libraries provided by Microsoft. These are a foundation of modern ASP.NET Core applications and support loading of configuration from many providers and sources. They can also be used with .NET Core worker services and just about any .NET project, which also uses the Microsoft dependency injection container and supports .NET Standard 2.0.
In this course, I will teach you everything you need to know about using configuration and options in .NET Core and ASP.NET Core. The skills you will learn will help you to build complex ASP.NET Core applications which can be configured from multiple sources.
Getting Started with Configuration Concepts
In this module, we explore how configuration can be provided for a .NET Core or ASP.NET Core applications. We focus on the prevalent JSON configuration provider for this module.
I introduce the IConfiguration interface, which can be injected into your controllers and services to consume the configuration values directly at runtime. I discuss how to bind sections of the configuration to classes and share some of the limitations of such an approach.
Clips in this module:
- Application Configuration in .NET Core
- Introducing the Tennis Booking Application
- Defining Configuration in JSON Files
- Accessing Configuration at Runtime
- Accessing Configuration Sections
- Accessing Configuration at Startup
- Downsides of Using IConfiguration Directly
- Binding Configuration
- Overriding Configuration Per Environment
Applying the Options Pattern
In this module, we fully explore the options pattern to learn how it can be applied to your applications. We investigate the three different options interfaces and understand how to choose between them. I explore in-depth, the potentially confusing array of options interfaces that can be injected to consume application configuration.
You’ll learn about more advanced concepts such as options validation and how you can leverage named options for repeated configuration structures.
We explore a technique to apply your own abstraction, which forwards to the underlying options services. We conclude by discussing how to unit test classes which take any of the options interfaces as a dependency.
Clips in this module:
- Introducing the Options Pattern
- Reloading Options Using IOptionsSnapshot
- Accessing Options Using IOptionsMonitor
- Using Named Options
- Applying Options Validation
- Advanced Options Validation
- Validating Named Options
- Choosing between Options Interfaces
- Forwarding to Options via an Interface
- Unit Testing Types Dependent on Options Classes
Working with Configuration Providers
This final module is dedicated to discussing the primary configuration providers that can load configuration from many different sources to build up the final application configuration.
You’ll learn how the configuration is populated as each provider is accessed to help you reason about your application configuration and re-order the registration of providers if necessary. We’ll discuss loading from environment variables, command-line arguments, user secrets, Azure Key Vault and AWS Parameter Store.
We’ll discuss an essential subject about the security considerations for storing sensitive configuration settings such as API keys and other secrets.
I’ll conclude by showing you how to define your own configuration provider to load settings from a database, accessed through Entity Framework Core.
Clips in this module:
- Configuration Providers
- How Configuration Is Populated
- Configuration Using Environment Variables
- Configuration Using Command Line Arguments
- Securing Sensitive Data in Configuration
- Securing Development Configuration with User Secrets
- Securing Production Configuration with Azure Key Vault
- Loading Configuration from AWS Parameter Store
- Customizing the Order of Configuration Providers
- Creating Custom Configuration Providers
Development of this Course
I’m incredibly proud to be developing content for Pluralsight, a platform I’ve been personally learning from for many years. One thing I never fully appreciated was the shear amount of time and effort that authors put into producing course content. In short, it’s a lot of hours. Over 100 for this course alone! Indeed, there’s a financial incentive for authors to produce courses. However, I believe that the quality of the content demonstrates that, for authors, there’s a passion for teaching and assisting others in understanding new topics that is more important than the income. At least it is for me! 🙂
This course took me four months end-to-end from proposal to submitting the final content such as the learning check questions and sample code. I consider it a labour of love and I aim to produce content of the highest quality for the development community to learn from.
I expect the production process may be quite interesting for people to read about, so perhaps I can write about that in a seperate blog post in the future.
For now, I hope people enjoy the course and find it useful! You can watch the course today with your Pluralsight subscription.