About configuration center of Apollo

A comparison among different configuration management tools

Use of Apollo configuration management portal: Installation manual on project Wiki

  1. Download source from github, either git clone or download zip
  2. in /script/dockerquickstart folder, check docker compose ports availability
  3. docker-compose up
  4. visit the mapped portal on server: 192.168.1.7:8070, login with user:apollo pass: admin Portal manual

Client usage in .net core UI Usage and Program.cs Startup.cs

Install package on nuget

Install-Package Com.Ctrip.Framework.Apollo.Configuration

appsettings.json

{
  "apollo": {
    "AppId": "dynamicforms-service", // This key comes from UI, create an application on UI and specify unique key.
    "MetaServer": "http://192.168.1.7:8081"
  }
}

program.cs

public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .ConfigureAppConfiguration((hostingContext, builder) =>
                {
                    builder
                    .AddApollo(builder.Build().GetSection("apollo"))
                    .AddDefault()
                    .AddNamespace("Common");//Apollo中NameSpace的名称,加上这个使配置在不同服务公用
                })
                .UseStartup<Startup>()
                .Build();

Verification works:

. Get config from apollo

var configValue=Configuration["apollokey"];
posted @ 2019-02-21 15:56  calochCN  阅读(283)  评论(0编辑  收藏  举报