.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
  }
}   
相关推荐
斯普信专业组2 天前
Nacos-MCP 融合架构:运维nacos的MCP服务项目
运维·nacos·架构
张3蜂2 天前
java springboot2.0 api ;.netcore8 api ;python GunicornAPI ,哪种更强?请从多个维度,对比分析
java·python·.netcore
切糕师学AI3 天前
.NET Core Web 中的健康检查端点(Health Check Endpoint)
前端·kubernetes·.netcore
魔芋红茶3 天前
NACOS 二次开发指南
nacos
xdpcxq10293 天前
.NET Core 双数据库 PostgreSQL 与 SQLite 和平共处
数据库·postgresql·.netcore
没有bug.的程序员4 天前
Spring Cloud Alibaba:Nacos 配置中心与服务发现的工业级深度实战
java·spring boot·nacos·服务发现·springcloud·配置中心·alibaba
思想在飞肢体在追5 天前
Springboot项目配置Nacos
java·spring boot·后端·nacos
小楼v6 天前
使用Nacos实现动态IP黑名单过滤
java·后端·微服务·nacos
九皇叔叔7 天前
【03】微服务系列 之Nacos 注册中心(服务注册)
java·微服务·nacos·架构·注册中心·服务注册