.net core 接入nacos

安装nacos

安装nacos

.net core 接入nacos

引用包

  • nacos-sdk-csharp
  • nacos-sdk-csharp.Extensions.Configuration

Program 代码

csharp 复制代码
        public static IHostBuilder CreateHostBuilder(String[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureAppConfiguration((hostingContext, builder) =>
                {
                    var config = builder.Build();
                    builder.AddNacosV2Configuration(config.GetSection("NacosConfig"));
                })
                .UseNacosConfig(section: "NacosConfig", parser: null, logAction: null)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                }).UseLogging();

配置文件

csharp 复制代码
{
  "NacosConfig": {
    "Listeners": [
      {
        "Optional": false,
        "DataId": "nacos.properties",
        "Group": "DEFAULT_GROUP"
      }
    ],
    "Namespace": "",
    "ServerAddresses": [ "http://nacos:8848" ],
    "UserName": "nacos",
    "Password": "nacos",
    "AccessKey": "",
    "SecretKey": "",
    "ConfigFilterassemblies": [ "YouPrefix.AssemblyName" ], 
    "ConfigFilterExtInfo": "some ext infomation", 
    "ConfigUsePrc": false, // http协议 为false grpc协议  为true
    "NamingUseRpc": false // http协议 为false grpc协议  为true
  }
}   
相关推荐
1-1=01 天前
C# 特性(Attribute)
c#·.net·.netcore
淡海水2 天前
10-01-互操作-C#与C++边界的内存管理
unity·c#·游戏引擎·.netcore·gc
1-1=02 天前
C# 反射
c#·.net·.netcore
-星空下无敌3 天前
Windows Docker K8s 安装部署Naocs ,SpringBoot 3.x 4.x 整合Naocs 版本兼容 配置中心、服务注册与发现
windows·docker·nacos·kubernetes·springboot·alibaba
1-1=03 天前
C# 泛型
c#·.net·.netcore
淡海水5 天前
09-01-内存-Unity资源生命周期全景
unity·c#·游戏引擎·.netcore·gc
1-1=05 天前
.NET Core 编译技术
.net·.netcore
1-1=06 天前
.NET Core 文件系统
.net·.netcore·1024程序员节
1-1=07 天前
.NET Core 内存管理
.net·.netcore
1-1=07 天前
.NET Core 配置与选项
.net·.netcore·1024程序员节