title: ASP.Net 6.0 Web API: Error <IDW10106: The 'Instance' option must be provided> when trying to use IConfiguration in controller
body: <p>I have currently an API controller looking like this:</p>
  <pre><code>public class WeatherForecastController : ControllerBase
  {
  
      public WeatherForecastController(ILogger&lt;WeatherForecastController&gt; _logger)
      {
      }
  
      [HttpGet(Name = &quot;GetWeatherForecast&quot;)]
      public IEnumerable&lt;WeatherForecast&gt; Get()
      {
          ...
      }
  }
  </code></pre>
  <p>And I have security settings in programm.cs like that:</p>
  <pre><code>// Microsoft Identity Authentication
  var jwtAuthentication = builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme);
  _ = jwtAuthentication.AddMicrosoftIdentityWebApi(builder.Configuration.GetSection(&quot;AzureAd&quot;));
  _ = jwtAuthentication.AddAppServicesAuthentication();
  ...
  app.UseAuthentication();
  app.UseAuthorization();
  </code></pre>
  <p>This all works fine so far. But when I now try to add IConfiguration parameter to the controller like this:</p>
  <pre><code>    public WeatherForecastController(ILogger&lt;WeatherForecastController&gt; _logger, IConfiguration _configuration)
      {
      }
  </code></pre>
  <p>A call to any operation of that controller ends with this exception:</p>
  <blockquote>
  <p>System.ArgumentNullException: IDW10106: The 'Instance' option must be
  provided.     at
  Microsoft.Identity.Web.MergedOptionsValidation.Validate(MergedOptions
  options)    at
  Microsoft.Identity.Web.MicrosoftIdentityWebApiAuthenticationBuilderExtensions.&lt;&gt;c__DisplayClass3_0.b__0(JwtBearerOptions
  options, IServiceProvider serviceProvider, IOptionsMonitor<code>1 mergedOptionsMonitor, IOptionsMonitor</code>1 msIdOptionsMonitor, IOptions<code>1 msIdOptions)    at Microsoft.Extensions.Options.ConfigureNamedOptions</code>5.Configure(String
  name, TOptions options)    at
  Microsoft.Extensions.Options.OptionsFactory<code>1.Create(String name)    at Microsoft.Extensions.Options.OptionsMonitor</code>1.&lt;&gt;c__DisplayClass10_0.b__0()
  at System.Lazy<code>1.ViaFactory(LazyThreadSafetyMode mode)    at System.Lazy</code>1.ExecutionAndPublication(LazyHelper
  executionAndPublication, Boolean useDefaultConstructor)    at
  System.Lazy<code>1.CreateValue()    at System.Lazy</code>1.get_Value()    at
  Microsoft.Extensions.Options.OptionsCache<code>1.GetOrAdd(String name, Func</code>1 createOptions)    at
  Microsoft.Extensions.Options.OptionsMonitor<code>1.Get(String name)    at Microsoft.AspNetCore.Authentication.AuthenticationHandler</code>1.InitializeAsync(AuthenticationScheme
  scheme, HttpContext context)    at
  Microsoft.AspNetCore.Authentication.AuthenticationHandlerProvider.GetHandlerAsync(HttpContext
  context, String authenticationScheme)    at
  Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext
  context, String scheme)    at
  Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext
  context)    at
  Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext
  httpContext)    at
  Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext
  httpContext, ISwaggerProvider swaggerProvider)    at
  Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware.InvokeInternal(HttpContext
  context)    at
  Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext
  context)</p>
  </blockquote>
  <p>As soon as I disable the security settings, all works fine again. In a way it smells, that the conroller construction is done differently when security settings are in place, and then the IConfiguration parameter is somehow a problem ...</p>
  <p>What do I have to change to make the controller run with both parameters ILogger and IConfiguration togheter with the given security settings?</p>