.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 天前
双库协同,各取所长:.NET Core 中 PostgreSQL 与 SQLite 的优雅融合实战
postgresql·sqlite·.netcore
吹牛不交税1 天前
admin.net-v2 框架使用笔记-netcore8.0/10.0版
vue.js·.netcore
CodeCaptain3 天前
nacos-2.3.2-OEM与nacos3.1.x的差异分析
java·经验分享·nacos·springcloud
斯普信专业组5 天前
Nacos-MCP 融合架构:运维nacos的MCP服务项目
运维·nacos·架构
张3蜂5 天前
java springboot2.0 api ;.netcore8 api ;python GunicornAPI ,哪种更强?请从多个维度,对比分析
java·python·.netcore
切糕师学AI6 天前
.NET Core Web 中的健康检查端点(Health Check Endpoint)
前端·kubernetes·.netcore
魔芋红茶6 天前
NACOS 二次开发指南
nacos
xdpcxq10296 天前
.NET Core 双数据库 PostgreSQL 与 SQLite 和平共处
数据库·postgresql·.netcore
没有bug.的程序员7 天前
Spring Cloud Alibaba:Nacos 配置中心与服务发现的工业级深度实战
java·spring boot·nacos·服务发现·springcloud·配置中心·alibaba