Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

local.settings.json not injected/included into environment variables when using a FunctionsStartup class.

Open JoeTomkinson opened this issue 4 years ago • 2 comments

Azure Function V4 - Can be easily replicated using the template solution in visual studio 2019/2022.

When you create an Azure function and you update the local.settings.json Values array with properties you want to access via Environment.GetEnvironmentVariables() they are pulled through successfully with no issues.

If you however want to use DI and you add in a FunctionsStartup class local.settings.json no longer get injected/included within the Environment Variables.

Now I realize that you can work around this by implementing IConfiguration. However the Microsoft Documentation states that the benefit of using GetEnvironmentVariables is that if we set up access to a Key Vault, the relevant keys can be pulled from that using GetEnvironmentVariables, so we don't have to necessarily write code to do this. It's nice and neat.

So I am unsure if this is a bug, or if it is acting as intended. The behavior seems to run counter to the official documentation.

JoeTomkinson avatar Jan 21 '22 15:01 JoeTomkinson

After doing a bit of investigating; my working theory is that creating a startup function overrides some of the boilerplate start-up logic for an Azure function.

I think that's likely intended in hindsight; but this could definately do with an update to the documentation for the FunctionStartup implementation.

JoeTomkinson avatar Jan 25 '22 16:01 JoeTomkinson

Hi @JoeTomkinson , Thank you for the feedback!

Tagging @ggailey777, Since its a document related issue. Can we add this in our documents and if its a valid note, then can we transfer this issue to the docs repo.

v-bbalaiagar avatar Feb 08 '22 15:02 v-bbalaiagar