.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
  }
}   
相关推荐
jasnet_u2 天前
SpringBoot服务优雅停机
nacos·springboot·优雅停机
多加点辣也没关系2 天前
Nacos 的安装(详细教程)
nacos
.NET修仙日记3 天前
.NET EFCore批量插入性能优化实战:30秒 → 0.5秒
性能优化·c#·.net·.netcore·微软技术·efcore·踩坑实录
环流_4 天前
nacos:健康检查机制
nacos
环流_4 天前
nacos:负载均衡 3大核心操作
运维·nacos·负载均衡
何中应5 天前
Nacos集群搭建
nacos·集群·高可用
Kimhill张6 天前
.net core8 WPF 依赖注入(DI)
wpf·.netcore
wangl_927 天前
C# / .NET 在工业环境中的优势
开发语言·c#·.net·.netcore·.net core·visual studio
devilnumber8 天前
Nacos 超精简精华版
nacos
庞轩px9 天前
第八篇:Spring与微服务——从SpringBoot到SpringCloud的演进
spring boot·spring·微服务·nacos·gateway·sentinel