Skip to content

Existing IConfiguration from builder.Services is lost #3

@andrewdmoreno

Description

@andrewdmoreno

Not sure when this started, but I am using v3 Azure Functions and when the below code runs, the ImplementationInstance is always null on the ServiceDescriptor. Perhaps the behavior has changed under the covers in recent versions, but it now requires calling BuildServiceProvider() and fetching the IConfguration from the IServiceProvider. The impact of this is that any modifications I make to host.json is lost when also using this package.

var descriptor = builder.Services.FirstOrDefault(d => d.ServiceType == typeof(IConfiguration));
if (descriptor?.ImplementationInstance is IConfigurationRoot configuration)
{
    configurationBuilder.AddConfiguration(configuration);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions