.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
  }
}   
相关推荐
geovindu5 天前
CSharp: Wordcloud
开发语言·后端·c#·.net·.netcore·词云
geovindu5 天前
CSharp: Command Pattern
开发语言·后端·c#·.net·.netcore·命令模式·行为模式
LayZhangStrive12 天前
后端开发中间件 - Nacos下载并快速使用教程
中间件·nacos
全栈小513 天前
【C#】.net core,静态方法线程安全解析,面试时经常被问的线程安全就藏在里面
安全·c#·.netcore
清风与日月15 天前
Yitter.IdGenerator:高性能分布式唯一ID生成器详解
分布式·c#·.net·.netcore
就叫_这个吧15 天前
java springcloud熔断降级组件sentinel基础应用及nacos持久化处理
java·spring cloud·nacos·sentinel
Lost of 程序猿18 天前
ASP.NET Core 后台任务全景:从 BackgroundService 到 Channel 队列,再到分布式调度
后端·asp.net·.netcore
宝桥南山19 天前
Blazor Web Assembly - 体验一下Authentication State从Server共享给Client
microsoft·微软·c#·asp.net·.net·.netcore
成为你的宁宁19 天前
【APISIX:部署、路由与 Nacos 集成】
微服务·nacos·apisix·api网关
linweidong22 天前
钉钉Java面经及参考答案
nacos·协程·垃圾收集器·jvm调优·spring ioc·脏读·mysql索引