Etcd Registration get start
#
ASP.NET Core projectFor ASP.NET Core project, we can refer to the example code at example code. What you need to do is quite simple and straightforward.
- add the Shenyu ASP.NET Core dependency into project.
dotnet add package Apache.ShenYu.AspNetCore
- in
Startup.ConfigureServices
method, add theShenyuRegister
service.
public void ConfigureServices(IServiceCollection services){ ... services.AddShenyuRegister(this.Configuration); ...}
- set your
Shenyu
configurations inappsettings.json
.
{ "Shenyu": { "Register": { "ServerList": "http://127.0.0.1:2379", "RegisterType": "etcd", "Props": { // etcd userName,if have not set ectd server userName,this parmas can empty "UserName": "", // etcd password,if have not set ectd server password,this parmas can empty "Password": "", // 3000 ms default "EtcdTimeout": 4000, // 5 ms default "EtcdTTL": 15 } }, "Client": { "AppName": "dotnetexampleetcd", "ContextPath": "/etcddotnet", "IsFull": false, "ClientType": "http" } }}
- enable calling via ip.
When running on your local machine, ASP.NET Core service can only be called from localhost
. To enable calling by IP,
you can replace https://localhost:{port};http://localhost:{port}
with https://*:{port};http://*:{port}
Setting by environment variables ASPNETCORE_URLS
. e.g. ASPNETCORE_URLS "http://*:5000"
export ASPNETCORE_URLS=http://+:5000
- start the application.
# build projectdotnet build --configuration Release# start projectcd examples/AspNetCoreExample/bin/Release/netcoreapp3.1dotnet AspNetCoreExample.dll
That's all! After finished above steps, you can start your project in IDE or below commands and you can
visit shenyu-admin
portal to see the APIs have been registered in Shenyu.