Azure-docs: Additional configuration providers

Created on 8 May 2019  Â·  15Comments  Â·  Source: MicrosoftDocs/azure-docs

How could we register additional configuration providers(eg. Azure App Configuration). The AddAzureAppConfiguration extension method extends IConfigurationBuilder, which is not exposed in the FunctionsStartup class.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 assigned-to-author azure-functionsvc doc-enhancement triaged

Most helpful comment

This is somewhat related to #30814, as they're both dealing with configuration. We should have a document section covering Configuration, which would address both issues.

/cc @jeffhollan @brettsam

All 15 comments

Hi @arkiaconsulting Thank you for your feedback! We will review and update as appropriate.

@fabiocav could you please share your thoughts here ?

Hi, I appeared to install need to install the package Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator to get this working

This is somewhat related to #30814, as they're both dealing with configuration. We should have a document section covering Configuration, which would address both issues.

/cc @jeffhollan @brettsam

@marctalary: what do you mean ? Could you please explain ?

Sure, I added the Microsoft.Azure.Functions.Extensions package to an
existing function app that didn't also include the
package Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.
In debug everything compiled and started without error but the function
failed when invoked with a DI error. After adding the package it started
working.

See https://github.com/marctalary/FunctionDiExample which has a copy of the
the Basic Function using the Microsoft.Azure.Functions.Extensions package
but it does not invoke the SampleStartup method and fails.

Thanks @fabiocav . I have assigned this to content author @ggailey777 to update the doc as appropriate.

Thanks @marctalary, I see, but I'm affraid that this isn't related to the present issue.

Does this also affect the usage of AddServiceBus()? I have a simple Service Bus triggered function and am unable to get it to bind the service bus extension after implementing this DI system.

Thanks @marctalary, I see, but I'm affraid that this isn't related to the present issue.
@arkiaconsulting you're right, apologies I meant to create a separate issue

@arkiaconsulting
following - https://github.com/Marcele1987 arcticle - http://marcelegger.net/azure-functions-v2-keyvault-and-iconfiguration?unapproved=31&moderation-hash=d6695c5977924b951f6351d647ec049d#comment-31 - I was able to add user-secrets to configuration. Until you get an official answer i think you can use same approach to integrate azure app configuration

code

var configurationBuilder = new ConfigurationBuilder();
            var descriptor = builder.Services.FirstOrDefault(d => d.ServiceType == typeof(IConfiguration));
            if (descriptor?.ImplementationInstance is IConfiguration configRoot)
            {
                configurationBuilder.AddConfiguration(configRoot);
            }
            var config = configurationBuilder.Build();
            configurationBuilder.AddUserSecrets<Startup>();
            config = configurationBuilder.Build();
            builder.Services.Replace(ServiceDescriptor.Singleton(typeof(IConfiguration), config));

@rameshjanjyam How are you setting/updating the values in "User Secrets"? I don't see any options when I right-click the project. Are you just using the command line?

@MisinformedDNA You have to add a UserSecretsId tag in your .csproj. See here

@MisinformedDNA yes I am using command line. as mentioned by @arkiaconsulting in my .csproj file I have UserSecretsId tag which is a guid

 <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
    <UserSecretsId>****guid ***** </UserSecretsId>
  </PropertyGroup>

and using cli commands (my development environment is on mac) like below I add secrets to UserSecrets
dotnet user-secrets set <key> <value>

Configuration support is a feature that the product team is investigating. Since this is more a product issue than a doc issue, I am going to #please-close this thread for now.

To request specific features, please feel free to open an issue propose them in the azure-functions-host repo.

Was this page helpful?
0 / 5 - 0 ratings