title: Weird exception when trying to use Dependency Injection in an Azure Function
body: <p>Given a File->New->Azure Functions v2 App, I'm trying to get a reference to either an <code>ILoggerFactory</code> or an <code>ILogger&lt;T&gt;</code>.</p>
  
  <p>I'm doing this in the <code>StartUp.cs</code> class which is ran on the function app start.</p>
  
  <p>Given the following code a weird exception is thrown:</p>
  
  <pre><code>var serviceProvider = builder.Services.BuildServiceProvider();
  var loggerFactory = serviceProvider.GetService&lt;ILoggerFactory&gt;();         
  </code></pre>
  
  <p>with the following exception:</p>
  
  <p><a href="https://i.stack.imgur.com/DkSUp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DkSUp.png" alt="enter image description here"></a></p>
  
  <pre><code> A host error has occurred
  [27/02/2019 8:21:22 AM] Microsoft.Extensions.DependencyInjection: Unable to resolve service for type 'Microsoft.Azure.WebJobs.Script.IFileLoggingStatusManager' while attempting to activate 'Microsoft.Azure.WebJobs.Script.Diagnostics.HostFileLoggerProvider'.
  Value cannot be null.
  Parameter name: provider
  </code></pre>
  
  <p>What is going on?</p>
  
  <p>The full test repo/code can be <a href="https://github.com/PureKrome/TestFunctionsApp" rel="noreferrer">found here on GitHub</a>.</p>