内容目录
Deploy Apollo and create an application.
Then create a namespace, select private to create a private namespace, and choose the json format.
Click modify text and fill in the json content.
Next, reference the package in the .NET program
<PackageReference Include="Com.Ctrip.Framework.Apollo.Configuration" Version="2.10.2" />
Define the Apollo settings in the configuration file.
{
"apollo": {
"AppId": "ApolloTest",
"MetaServer": "http://192.168.80.70:8080",
"ConfigServer": "http://192.168.80.70:8080",
"Env": "DEV",
"Namespaces": [
"DEV"
]
},
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Debug"
}
},
"AllowedHosts": "*"
}
Finally, inject it in the code:
var builder = WebApplication.CreateBuilder(args);
builder.Host.ConfigureAppConfiguration(b =>
{
b.AddApollo(builder.Configuration.GetSection("apollo")).AddNamespace("DEV",ConfigFileFormat.Json);
});
文章评论