Experiencing .NET configurations
In this chapter, we will create a new Web API project to try out .NET configuration features before adding configuration features to the game APIs and the bot service:
dotnet new webapi -o ConfigurationPrototype
.NET is flexible in how to read configuration values. Configuration values can be retrieved from different sources such as JSON files, environment variables, and command-line arguments. Depending on the environment (for example, production and development), different configuration values are also retrieved. Using this core .NET feature, it’s easily possible to add other configuration sources and customize environments.
Behind the scenes, the ConfigurationManager
class is used to configure sources for the application configuration. This configuration is done at application startup when invoking WebApplication.CreateBuilder
.
Note
With .NET 8, other builder methods, such as CreateSlimBuilder
and CreateEmptyBuilder
, are available...