Giter Site home page Giter Site logo

functionwithkeyvaultanddi's Introduction

Azure Function App with KeyVault and DI

An Azure Function App example with Dependency Injection and the Key Vault as Configuration Provider

See Knowledge Base article for detailed description.

functionwithkeyvaultanddi's People

Contributors

marcelwolterbeek avatar forestbrook avatar

Stargazers

Mike Kostov avatar

Watchers

James Cloos avatar  avatar Kilian Seizinger avatar

functionwithkeyvaultanddi's Issues

Wrong order of configuration providers

Hi
I've read your post https://www.forestbrook.net/docs/azure/functionwithkeyvaultanddi.html and highly appreciated it! Thank you!!!

But I've found an issue/problem with how Azure Functions work, and the way you add the configuration providers for appsettings.json files.
Nothing wrong really, but since the appsettings JSON configurations providers (configurationsource) are added after the ones provided by Azure Functions, they will override any value you specify in the application settings in the Azure portal for your Azure function.
You can also test it locally and see that, for any setting that has value both in appsettings.json and in local.settings.json, the last added providers (appsettings.json) wins.

If we compare that to appsettings.json and application settings on an Azure App Service, it is the other way around - the application settings "overrides" any setting in appsettings.json.

To solve it properly, we would need to change code in the Azure Functions framework, but I've come up with a workaround, which needs bo be invoked after adding the appsettings.json fileproviders, and before adding the KeyVault provider.

        private static void PrioritizeEnvironmentVariables(IFunctionsConfigurationBuilder builder)
        {
            var commandlineProvider = builder.ConfigurationBuilder.Sources.LastOrDefault(x => x is Microsoft.Extensions.Configuration.EnvironmentVariables.EnvironmentVariablesConfigurationSource);
            if (commandlineProvider != null)
            {
                builder.ConfigurationBuilder.Sources.Remove(commandlineProvider);
                builder.ConfigurationBuilder.Sources.Add(commandlineProvider);
            }
        }

I hope it was OK to add this feedback as an issue. I could not easily find another way to contact you.

Best regards
Marcus Nilsson

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.