Azure Function Python v2 layout/structure - advice for managing multiple Python files in 2024

I’ve started an Azure Function Python v2 project in Visual Studio Code. This created a certain directory layout for an AF repo.

I’ve been splitting up components into separate Python files that I can import, to keep things organized and understandable. All of this started in a test script that I have only run locally, so I haven’t even tried this in Azure as an AF yet.

I’m not clear how the AF files should be layed out, at least when it comes to my extra Python file that I intend to import into the function_app.py. The VSC tool created:

  • .funcignore
  • .gitignore
  • function_app.py
  • host.json
  • local.settings.json
  • requirements.txt

I also ended up with the following, but not sure when/how I got it:

  • src/

I am not sure if my additional Python files should end up in a directory structure like:

  • ./src/function_name directory - a general Python “src” packaging recommendation
  • ./__app__/ directory and subdirectories - a general AF recommendation, but this may be for v1 rather than v2 based on Microsoft docs
  • ./function_name directory - Python “flat” packaging
  • something else

I would want to be able to test the AF locally and it does need to be run as an AF eventually.

Thanks in advance for any ideas/advice.