Skip to content

Help with setting up dependency injection #1560

Answered by Magnus-K-work
kuromukira asked this question in Q&A
Discussion options

You must be logged in to vote

At the end of SDK Basics / Getting started / Configuring the needed services there is an alternative setup that I used in my test application and it works fine with Dependency Injection. See below, I removed some code that set options and such but the options.DefaultAuthenticationProvider property is the interesting part:

var host = Host.CreateDefaultBuilder()
// Set environment to use
.UseEnvironment("demo") // you can eventually read it from environment variables
// Configure logging
.ConfigureServices((hostingContext, services) =>
{
  // Read the custom configuration from the appsettings.<environment>.json file
  var customSettings = new CustomSettings();
  hostingContext.Configuration…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kuromukira
Comment options

Answer selected by kuromukira
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants