Search code examples
.netconsul

Service name is missing Consul


I am trying to add service to consul through configuration file.

While doing so, I am getting the following error.

Error Message:-

==> Starting Consul agent...
==> Error starting agent: failed adding service "12WCF": Service name missing

Code Used:

{
"service": {
    "name": "WCF",  
    "id" : "12WCF",
    "address" : "127.0.0.1",
    "port": 62133        
}
}

Command:- consul.exe agent --dev

I am using Windows for development.

I have provided the service name in the config. But still it is says as, service name is missing.

Am I missing any other thing.

Could any one provide some suggestions on it.

Thanks.


Solution

  • Ah,

    Got it. So, we have to add an attrib named "service" to the json which solves the problem.

    So, the final config will look like,

    {
    "service": {
    "id":"somename",
    "name":"nameofthissevice",
    "service": "myservice",
    "address": "127.0.0.1",
    "port": 62133
    }
    }
    

    Do not know why consul did not mention this in their docs.

    Thx.