『AgileConfig』. NET lightweight configuration center agileconfig

Posted by CorfuVBProgrammer on Wed, 02 Feb 2022 12:15:09 +0100


The lightweight configuration center developed based on NetCore is simple to deploy, configure and use. It can be adopted according to the needs of individuals or companies.

  • Deployment brief answer: at least one data node is required to support docker deployment
  • Support multi node distributed deployment to ensure high availability
  • In application isolation configuration is supported
  • Using long link technology, the configuration information is pushed to the client in real time
  • It supports IConfiguration and IOptions mode reading configuration, and the original program hardly needs to be modified
  • Configuration modification supports version recording, and the configuration can be rolled back at any time
  • All nodes fail, and the client supports reading the configuration from the local cache

GitHub address: https://github.com/kklldog/AgileConfig You can order a star for this big man


The architecture of AgileConfig is relatively simple, which is mainly divided into three parts:


The client program uses netstandard2 0 development of a class library, convenient net core program access, nuget search agileconfig Client can be installed. You can configure the addresses of multiple nodes when starting the client. The client will randomly select one to connect. After the connection is successful, a websocket long connection will be maintained. If the connection is interrupted due to the failure of the connected node, the client will continue to connect with a random node until the connection is successful.

Nodes and management procedures

The node uses ASP Net core. In order to simplify deployment, the hypervisor and node services are directly integrated. Any node can configure the environment variable to enable the hypervisor function at startup.


Database is used to store data. At present, sqlserver, MySQL and SQLite databases are supported. Because the server uses the EF Core framework to access data, in principle, as long as the EF Core supports the database, the node can easily support it.

Deployment server

Through docker deployment, it currently supports five databases: sqlserver, mysql, sqlite, PostgreSql and Oracle. This example uses lightweight sqlite as data storage

sudo docker run --name agile_config -e adminConsole=true -e db:provider=sqlite -e db:conn="Data Source=agile_config.db" -p 5000:5000 kklldog/agile_config:latest
  1. Create an agile through docker_ Config instance, in which three environment variables need to be configured:
  2. Whether the adminConsole configurator is an administrative console. If true, the console function will be enabled, and the management interface will appear when accessing the instance.
    DB: the database type of the provider configurator. At present, the program supports three databases: sqlite, mysql and sqlserver.
  3. db:conn configuration database connection string

Enter the system

Access our address via browser: http://localhost:5000/

The interface is simple and beautiful. You need to initialize the administrator password for the first login, and then log in to the system

Through the main interface, we can see the following menus

Nodes: AgileConfig supports multi node deployment, and all nodes are parallel. To simplify deployment, AgileConfig does not have a separate console program. Please directly use any node as the console.

Application: AgileConfig supports multi application access. You need to configure the name, ID, secret key and other information for each application. Each application can set whether it can be inherited. Applications that can be inherited are similar to the concept of apollo's public namespace. Public configurations can be extracted into inheritable applications, and other applications can obtain all configurations as long as they inherit it. If the configuration key between the child application and the inherited application is duplicated, the configuration of the child application will overwrite the configuration of the inherited application. Sub applications can inherit multiple applications. If duplicate keys occur between multiple applications, the configuration of the later inherited application will overwrite the previous application according to the order of inheritance.

After creating an application, we can click the configuration item of the application in the list.

The newly added configuration will not be perceived by the client. You need to manually click "go online" to push it to the client.

If the online configuration is modified, deleted or rolled back, it will be pushed to the client in real time. The version history records the historical information of the configuration and can be rolled back to any version.

Client: you can view the connected clients

Log: a log that records some key information

Create client

Install-Package AgileConfig.Client

Connect to our configuration center and configure in the program

public class Program
        public static IConfigClient ConfigClient;

        public static void Main(string[] args)

        public static IHostBuilder CreateHostBuilder(string[] args) =>
                .ConfigureAppConfiguration((context, config) =>
                    //Read local configuration
                    var localconfig = new ConfigurationBuilder()
                    //Read the relevant information of AgileConfig from the local configuration
                    var appId = localconfig["AgileConfig:appId"];
                    var secret = localconfig["AgileConfig:secret"];
                    var nodes = localconfig["AgileConfig:nodes"];

                    //new a client instance
                    var configClient = new ConfigClient(appId, secret, nodes);
                    //Use AddAgileConfig to configure a new IConfigurationSource
                    //Find a variable to mount the client instance so that other places can directly use the instance to access the configuration
                    ConfigClient = configClient;
                    //Registration configuration item modification event
                    configClient.ConfigChanged += ConfigClient_ConfigChanged;
                .ConfigureWebHostDefaults(webBuilder =>


        ///This event will be triggered when a configuration item is added, modified, or deleted
        private static void ConfigClient_ConfigChanged(ConfigChangedArg obj)
            Console.WriteLine($"action:{obj.Action} key:{obj.Key}");

            switch (obj.Action)
                case ActionConst.Add:

                case ActionConst.Update:

                case ActionConst.Remove:


appsettings add

 "AgileConfig": {
    "appId": "test",
    "secret": "123",//secret key
    "nodes": "http://localhost:5000 "/ / multiple nodes are separated by commas

Topics: .NET agile