ASP.NET Core Web API Interview Question #170

What is the role of environment-specific configuration during deployment?

Testing, HttpClient, Integration Testing, Background Services & Deployment Senior Advanced

Quick Interview Answer

ASP.NET Core can load configuration from appsettings files, environment variables, secret stores, command-line values, and other providers. Deployment environments should supply values such as connection strings, service endpoints, logging levels, and feature settings without requiring source-code changes.

Detailed Explanation

ASP.NET Core can load configuration from appsettings files, environment variables, secret stores, command-line values, and other providers. Deployment environments should supply values such as connection strings, service endpoints, logging levels, and feature settings without requiring source-code changes.

Secrets should be stored in an appropriate secret-management system rather than committed to configuration files in source control.

Code Example

var connectionString =
    builder.Configuration.GetConnectionString("Default");

var apiUrl =
    builder.Configuration["Services:CatalogUrl"];