Overview
Each service usesappsettings.json for configuration. These settings can be overridden by environment-specific files (appsettings.Development.json, appsettings.Production.json) or environment variables.
Configuration Structure by Service
Catalog API
File:Services/Catalog/Catalog.API/appsettings.json
| Section | Key | Description | Default Value |
|---|---|---|---|
| ConnectionStrings | Database | PostgreSQL connection string | localhost:5432 |
| Logging | Default | Default log level | Information |
| Logging | Microsoft.AspNetCore | ASP.NET Core log level | Warning |
| - | AllowedHosts | CORS allowed hosts | * (all) |
Basket API
File:Services/Basket/Basket.API/appsettings.json
| Section | Key | Description | Default Value |
|---|---|---|---|
| ConnectionStrings | Database | PostgreSQL connection string | localhost:5433 |
| ConnectionStrings | Redis | Redis cache connection | localhost:6379 |
| GrpcSettings | DiscountUrl | Discount gRPC service URL | https://localhost:5052 |
| MessageBroker | Host | RabbitMQ host address | amqp://localhost:5672 |
| MessageBroker | UserName | RabbitMQ username | guest |
| MessageBroker | Password | RabbitMQ password | guest |
- PostgreSQL for cart persistence
- Redis for distributed caching
- gRPC client for discount service
- MassTransit with RabbitMQ for event publishing
Discount gRPC
File:Services/Discount/Discount.Grpc/appsettings.json
| Section | Key | Description | Default Value |
|---|---|---|---|
| ConnectionStrings | Database | SQLite database file | discountdb |
| Kestrel | Protocols | HTTP protocol version | Http2 (gRPC) |
| Logging | Default | Default log level | Information |
| Logging | Microsoft.AspNetCore | ASP.NET Core log level | Information |
Kestrel.EndpointDefaults.Protocols is set to Http2 to enable gRPC communication.
Database: Uses Entity Framework Core with SQLite for lightweight discount storage.
Ordering API
File:Services/Ordering/Ordering.API/appsettings.json
| Section | Key | Description | Default Value |
|---|---|---|---|
| ConnectionStrings | Database | SQL Server connection string | localhost:1433 |
| MessageBroker | Host | RabbitMQ host address | amqp://localhost:5672 |
| MessageBroker | UserName | RabbitMQ username | guest |
| MessageBroker | Password | RabbitMQ password | guest |
| FeatureManagement | OrderFullfilment | Feature flag for order fulfillment | false |
- SQL Server with Entity Framework Core
- MassTransit with RabbitMQ for consuming basket checkout events
- Feature flags for controlling order fulfillment workflow
Encrypt=False: Disables SSL encryption (dev only)TrustServerCertificate=True: Bypasses certificate validation (dev only)
YARP API Gateway
File:ApiGateways/YarpApiGateway/appsettings.json
| Route | Path Pattern | Backend Service | Rate Limiting |
|---|---|---|---|
| catalog-route | /catalog-service/* | http://catalog.api:8080 | No |
| basket-route | /basket-service/* | http://basket.api:8080 | No |
| ordering-route | /ordering-service/* | http://ordering.api:8080 | Yes (fixed window) |
Program.cs):
- Policy: Fixed Window
- Window: 10 seconds
- Permit Limit: 5 requests per window
- Incoming:
/catalog-service/products - Transformed:
/products(service receives without prefix)
appsettings.Local.json):
Shopping Web
File:WebApps/Shopping.Web/appsettings.json
| Section | Key | Description | Default Value |
|---|---|---|---|
| ApiSettings | GatewayAddress | YARP Gateway base URL | https://localhost:6064 |
- Uses Refit for HTTP client generation
- All services accessed through the gateway
- Service endpoints:
- Catalog:
{GatewayAddress}/catalog-service - Basket:
{GatewayAddress}/basket-service - Ordering:
{GatewayAddress}/ordering-service
- Catalog:
Common Configuration Sections
Logging
All services use standard ASP.NET Core logging configuration:AllowedHosts
Environment-Specific Configuration
Development Settings
Minimal overrides inappsettings.Development.json:
Docker Settings
In Docker environments, settings are primarily controlled via environment variables indocker-compose.override.yml rather than separate appsettings files.
Configuration Best Practices
Use User Secrets for Development
Use User Secrets for Development
Store sensitive data in User Secrets during development:
Environment Variables in Production
Environment Variables in Production
Override sensitive settings using environment variables:Note: Use double underscores (
__) to represent nested JSON levels.Azure App Configuration
Azure App Configuration
For production, consider using Azure App Configuration or Azure Key Vault:
Feature Flags
Feature Flags
Use the FeatureManagement section for feature toggles:
