Introduction
Quick Start
To get up and running with Fig, you'll need to set up the API, Web and integrate the client nuget package into your application.
Install API and Web Client
The API and Web Clients can be installed using Docker. This guide assumes docker is installed and running.
Clone the fig repository and use the
docker-compose.yml
file included.Open a terminal / command prompt, navigate to the directory containing the docker-compose file and type
docker-compose up
to download the containers and run them.
Log in to Web Client
Navigate to http://localhost:8080 and at the login prompt enter user: admin
password: admin
. You should see the administration view of fig with all options available.
Integrate Client
In this guide, we'll create an ASP.NET project from scratch and integrate the Fig.Client to use fig for configuration. However the same instructions apply if you have an existing project. Just skip the project creation.
Create new ASP.NET project
dotnet new
Open the project in your favourite
Add Fig.Client nuget package
Create a new class to hold your application settings, extending the SettingsBase class. For example:
public class ExampleSettings : SettingsBase
{
public override string ClientName => "ExampleService";
[Setting("My favourite animal", "Cow")]
public string FavouriteAnimal { get; set; }
[Setting("My favourite number", 66)]
public int FavouriteNumber { get; set; }
[Setting("True or false, your choice...", false)]
public bool TrueOrFalse { get; set; }
}Register Fig as a configuration provider in the
program.cs
file.var configuration = new ConfigurationBuilder()
.AddFig<Settings>(o =>
{
o.ClientName = "AspNetApi";
}).Build();Access the settings via the IOptions or IOptionsMonitor interface. E.g.
public WeatherForecastController(IOptionsMonitor<ExampleSettings> settings)
{
_settings = settings;
}Add an environment variable called FIG_API_URI with the URI of the Fig API. For example:
FIG_API_URI=https://localhost:7281
Add a client secret (see Client Configuration section for details on how to do that)
See the examples folder in the source repository for more examples.