To create a .NET service which is registered with Eureka we’ll use the Steeltoe libraries…
Create an ASP.NET Core Web Application and select WebApi. Add the Steeltoe.Discovery.Client NuGet package, now in the Startup.cs within ConfigureServices add the following
services.AddDiscoveryClient(Configuration);
and within the Configure method add
app.UseDiscoveryClient();
We’re not going to create any other code to implement a service, but we will need some configuration added to the appsettings.json file, so add the following
"spring": { "application": { "name": "eureka-test-service" } }, "eureka": { "client": { "serviceUrl": "http://localhost:8761/eureka/", "shouldRegisterWithEureka": true, "shouldFetchRegistry": false }, "instance": { "hostname": "localhost", "port": 5000 } }
The application name is what’s going to be displayed within Eureka and visible via http://localhost:8761/eureka/apps (obviously replacing the host name and ip with your Eureka server’s).