title: How can I use the new DI to inject an ILogger into an Azure Function using IWebJobsStartup?
body: <p>I am using <code>Azure Function</code> v2. Here is my function that uses the constructor injection:</p>
  
  <pre><code>public sealed class FindAccountFunction
  {
      private readonly IAccountWorkflow m_accountWorkflow;
  
      private readonly IMapper m_mapper;
  
      private readonly ILogger m_logger;
  
      public FindAccountFunction(ILogger logger, IMapper mapper, IAccountWorkflow accountWorkflow)
      {
          m_logger = logger;
          m_mapper = mapper;
          m_accountWorkflow = accountWorkflow;
      }
  
      [FunctionName("FindAccount")]
      public async Task&lt;IActionResult&gt; Run(
              [HttpTrigger(AuthorizationLevel.Function, Verbs.Get, Route = "v1/accounts/")] HttpRequest httpRequest, ILogger logger)
      {
          // Do stuff.
      }
  }
  </code></pre>
  
  <p>I am declaring all the dependencies that I want to inject into my Azure Function in the Startup class that derives from <code>IWebJobsStartup</code>: </p>
  
  <pre><code>    public sealed class Startup : IWebJobsStartup
      {
          public void Configure(IWebJobsBuilder webJobsBuilder)
          {
              //  Registers the application settings' class.
              webJobsBuilder.Services.AddSingleton&lt;IApplicationSettings, ApplicationSettings&gt;();
  
              //  ** Registers the ILogger instance **
              //  ** ?? **
  
              //  Registers the IMapper instance for the contracts.
              var mapperConfiguration = new MapperConfiguration(cfg =&gt; cfg.AddProfile(new MyProfile()));
  
       webJobsBuilder.Services.AddSingleton(mapperConfiguration.CreateMapper());
  
              // Registers custom services.
              webJobsBuilder.Services.AddTransient&lt;IStorageService, StorageService&gt;();
  
              webJobsBuilder.Services.AddTransient&lt;IAccountWorkflow, AccountWorkflow&gt;();
          }
     }
  </code></pre>
  
  <p>The Azure Function calls other injected services that do depends on the ILogger as well, such as the <code>IAccountWorkflow</code>:</p>
  
  <pre><code>public sealed class AccountWorkflow : IAccountWorkflow
  {  
      public AccountWorkflow(ILogger logger, IStorageService storageService)
      {
          if(logger is null)
              throw new ArgumentNullException();
      }
  }
  </code></pre>
  
  <p>The problem is that the DI is unable to find any <code>ILogger</code> implementation and fails to resolve services since a null <code>ILogger</code> is injected. </p>
  
  <p><strong>Question</strong></p>
  
  <p>How can I setup the injection of the <code>ILogger</code> in <code>IWebJobsStartup</code>?</p>