1. 服務(wù)注冊(cè)
對(duì) Consul 進(jìn)行服務(wù)注冊(cè)之前,需要先部署一個(gè)服務(wù)站點(diǎn),我們可以使用 ASP.NET Core 創(chuàng)建 Web 應(yīng)用程序,并且部署到 Ubuntu 服務(wù)器上。
ASP.NET Core Hell World 應(yīng)用程序示例代碼,只需要三個(gè)文件,Startup.cs
代碼:
public class Startup{ // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); }