how python finds where to environment variables if same variable is defined in two files

krishna572 876 Reputation points
2023-02-24T13:39:22.3466667+00:00

There are two files for storing the environment variables such as

  1. local.settings.json file
  2. .env file

I know that Azure Functions Project will pick up the environment variables from the file local.settings.json but how it ignores the .env file because it is also does the same job in python projects.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,185 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,211 Reputation points
    2023-02-28T17:31:40.2433333+00:00

    Vaishnavi Thanks for posting this question in Microsoft Q&A. Based on the statement above, I assume you are running Azure Function locally, which uses Azure Function Core Tools. Currently, there is no support for .env file in Azure Function Core Tools which means it never tries to process the file at all. Hence. only local.settings.json is supported (refer #1129).

    In other python projects, there might be a package or library (like python-dotenv library which has load_dotenv()) that can be used code to import .env file. That's not case in Function Core Tools and feel free to check the source code in GitHub https://github.com/Azure/azure-functions-core-tools

    To add more context, for example, it loads local.settings.json https://github.com/Azure/azure-functions-core-tools/blob/v4.x/src/Azure.Functions.Cli/StaticResources/StaticResources.cs#L66 and used it other places.

    I hope this helps with your question and feel free to add a comment if you have any other questions. Would be happy to answer.


    If you found the answer to your question helpful, please take a moment to mark it as "Yes" for others to benefit from your experience.

    0 comments No comments

0 additional answers

Sort by: Most helpful