Skip to content

Quick start solution for getting started using Fig for configuration management.

License

Notifications You must be signed in to change notification settings

mzbrau/fig-quick-start

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fig Quick Start

Build Status

A comprehensive example demonstrating how to use Fig for configuration management in .NET applications. This solution showcases Fig's powerful features through a sample Weather API built with .NET Aspire.

Running the Example

  1. Clone the repository
  2. Start the app host
  3. Click the Fig Web in the aspire dashboard
  4. Log in with 'admin' and 'admin'
  5. Change / update some settings
  6. Navigate to the swagger page for the weather api and validate that settings have changed

Dashboard
An example of how the dashboard will look

See detailed for detailed steps.

About Fig

Fig is a dynamic configuration management system that enables real-time configuration updates without application restarts. For complete documentation, visit figsettings.com.

Solution Components

WeatherApi

A REST API that provides weather forecast data with fully configurable behavior through Fig. Demonstrates real-time configuration updates affecting API responses without requiring restarts or redeployments. Data is all mocked.

AppHost (.NET Aspire)

Orchestrates the application stack including:

  • Fig API service (backend configuration API) (via docker)
  • Fig Web interface (configuration management UI) (via docker)
  • WeatherApi service with Fig integration

ServiceDefaults

Contains shared service configuration and telemetry setup for the distributed application.

WeatherApi.Test

Integration test suite demonstrating how to test Fig-enabled applications using in-memory configuration.

Fig Features Demonstrated

Configuration Categories

Settings are organized into logical categories with custom colors:

  • General - Core application settings (Location, ForecastDays)
  • Display - UI/output formatting options (TemperatureUnit, DescriptionStyle)
  • Temperature Range - Operational constraints (MinTemperature, MaxTemperature)
  • API Integration - External service configuration (ApiKey, ApiBaseUrl, Caching)

Validation

Multiple validation approaches showcased:

  • Attribute-based validation - [ValidateIsBetween], [ValidValues], [Validation(ValidationType.NotEmpty)]
  • Custom validation logic - Complex rules in GetValidationErrors() method
  • Cross-field validation - Ensuring MinTemperature < MaxTemperature

Advanced Features

  • Secrets Management - [Secret] attribute for sensitive data like API keys
  • Conditional Settings - [DependsOn] for conditional visibility (CacheDurationMinutes only shown when EnableCaching is true)
  • Multi-line Input - [MultiLine] attribute for longer text fields
  • Enum Support - [ValidValues(typeof(TEnum))] for strongly-typed options
  • External Documentation - Settings reference external markdown documentation ($weather-api)
  • Secret Providers - Supports Docker Secrets and DPAPI for secure credential storage
  • Real-time Updates - Configuration changes instantly affect application behavior
  • Integration Testing - In-memory configuration for isolated testing

Documentation

Example of how documentation can be drawn from a markdown file

Health Checks

Example of how Fig can display the status of a health check

Getting Started

Prerequisites

  • .NET 10 SDK
  • Docker Desktop / Docker hosting solution like WSL (for Fig API and Web containers)

Running the Solution (Detailed)

  1. Clone the repository:
git clone https://github.com/mzbrau/fig-quick-start.git
cd fig-quick-start
  1. Navigate to the solution directory:
cd src/Fig.QuickStart
  1. Run the AppHost to start all services:
dotnet run --project Fig.QuickStart.AppHost

The .NET Aspire dashboard will open automatically, showing:

  • Fig Web - Configuration management UI
  • Fig API - Backend configuration service
  • WeatherApi - Sample API with Fig integration
  1. Access the services:
  • Fig Web UI: http://localhost:7148
  • WeatherApi: Check Aspire dashboard for assigned port
  • Aspire Dashboard: http://localhost:15225 (or as shown in console)

Exploring Configuration

  1. Open Fig Web UI at http://localhost:7148
  2. Navigate to the WeatherApi client
  3. Modify settings like Location, ForecastDays, or TemperatureUnit
  4. Call the WeatherApi endpoint and observe immediate changes
  5. No restart required!

Running Tests

cd src/Fig.QuickStart
dotnet test Fig.QuickStart.WeatherApi.Test

Project Structure

fig-quick-start/
├── docs/
│   └── weather-api.md          # Configuration documentation
├── src/
│   └── Fig.QuickStart/
│       ├── Fig.QuickStart.AppHost/         # .NET Aspire orchestration
│       ├── Fig.QuickStart.ServiceDefaults/ # Shared service configuration
│       ├── Fig.QuickStart.WeatherApi/      # Sample API with Fig
│       └── Fig.QuickStart.WeatherApi.Test/ # Integration tests
└── README.md

Resources

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

About

Quick start solution for getting started using Fig for configuration management.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published