title: How do you initialize DocumentDB client as a Singleton in a dotnet core application
body: <p>I am building a MVC Web application in .net core and will be using CosmosDB with the DocumentDB API.  I keep reading that for preformance you should</p>
  
  <blockquote>
    <p>Use a singleton DocumentDB client for the lifetime of your application Note that each DocumentClient instance is thread-safe and performs efficient connection management and address caching when operating in Direct Mode. To allow efficient connection management and better performance by DocumentClient, it is recommended to use a single instance of DocumentClient per AppDomain for the lifetime of the application.</p>
  </blockquote>
  
  <p>but I am unsure of how to do this.</p>
  
  <p>I will using the following code to inject my services into my controllers, which each correspond to a different collection.</p>
  
  <pre><code>services.AddScoped&lt;IDashboard, DashboardService&gt;();
  services.AddScoped&lt;IScheduler, SchedulerService&gt;();
  services.AddScoped&lt;IMailbox, MailboxService&gt;();
  </code></pre>
  
  <p>How do I create the DocumentDB client as a Singleton and inject/use it in these services?</p>