title: DI in Azure Function using Simple Injector
body: <p>I want to use Simple Injector to inject command handlers, ILogger and TelemetryClient in Azure Fuctions.</p>
  
  <p>Here is my Azure Function:</p>
  
  <pre class="lang-cs prettyprint-override"><code>[FunctionName("ReceiveEvent")]
  public static async Task&lt;IActionResult&gt; Run(
      [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
      ILogger log,
      ICommandMapper commandMapper,
      ICommandValidator commandValidator,
      ICommandHandlerService commandHandlerService)
  {
      log.LogInformation("ReceiveEvent HTTP trigger function started processing request.");
  
      IActionResult actionResult = null;
  
      string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
  
      var command = await commandMapper.Map(requestBody);
  
      if (commandValidator.Validate(req, command, ref actionResult))
      {
          //TODO
          commandHandlerService.HandleCommand(command);
          return actionResult;
      }
  
      return actionResult;
  }
  </code></pre>
  
  <p>Here is my Bootstrapper class:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class Bootstrapper
  {
      public static void Bootstrap(IEnumerable&lt;Assembly&gt; assemblies = null, bool verifyContainer = true)
      {
          Container container = new Container();
  
          container.Register(typeof(ICosmosDBRepository&lt;&gt;), typeof(CosmosDBRepository&lt;&gt;).Assembly);
          container.Register(typeof(IAzureBlobStorage), typeof(AzureBlobStorage).Assembly);
          container.Register(typeof(ICommandMapper), typeof(CommandMapper).Assembly);
          container.Register(typeof(ICommandValidator), typeof(CommandValidator).Assembly);
          container.Register(typeof(ICommandHandlerService), typeof(CommandHandlerService).Assembly);
  
          List&lt;Assembly&gt; myContextAssemlies = new List&lt;Assembly&gt;
              {
                   Assembly.GetAssembly(typeof(CardBlockCommandHandler)),
              };
  
          container.Register(typeof(ICommandHandler), myContextAssemlies, Lifestyle.Scoped);
  
          assemblies = assemblies == null
              ? myContextAssemlies
              : assemblies.Union(myContextAssemlies);
  
          if (verifyContainer)
          {
              container.Verify();
          }
      }
  }
  </code></pre>
  
  <p>Now my question is, how I'll resolve the DI with this bootstrapper method in Azure Function?</p>
  
  <p>Do I need to register bootstrap method in FunctionsStartup?</p>