title: How to self register a service with Consul
body: <p>I'm trying to <a href="http://microservices.io/patterns/self-registration.html" rel="noreferrer">self</a> register my ASP.NET Core application to Consul registry on startup and deregister it on shutdown.</p>
  
  <p>From <a href="https://www.consul.io/docs/agent/http/agent.html#agent_service_register" rel="noreferrer">here</a> I can gather that calling the http api [<code>put /v1/agent/service/register</code>] might be the way to go (or maybe not!).</p>
  
  <p>From my app, I thought I'll target the <code>Startup</code> class, starting with adding the my <code>.json</code> file</p>
  
  <pre><code>public Startup(IHostingEnvironment env)
  {
     var builder = new Configuration().AddJsonFile("consulconfig.json");
     Configuration = builder.Build();
  }
  </code></pre>
  
  <p>But now, I'm stuck as <code>ConfigureServices</code> method tells me thats where I add services to the container, and <code>Configure</code> method is where I configure the Http request pipeline.</p>
  
  <p>Anybody to point me in the right directions, online readings, examples, etc.                                        </p>