Append /home/site/wwwroot to sys.path #726
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Content In This PR
Create a unittest friendly folder structure: #469
import a as b
statementDescription
The current Python function app folder structure suggested in https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python#folder-structure is confusing:
__app__
which is not a Python standard. This makes Azure Functions Python code less portable.We want to enable unit tests and absolute import to our customers, and make our customers code more portable.
Fix sys.path
We found out the sys.path is inconsistent across Linux Consumption, Linux Dedicated/Premium, and Local Development environment. After we discussed with Brett and Steve, we decide to align these environments by introducing the project root into sys.path.
Linux Consumption:
Linux Dedicated/Premium:
Local Development using Core Tools and VSCode:
Message to customer
__app__
import.__init__.py
file into the SharedCode folder to make it a Python package, and feel free to useimport SharedCode
orfrom SharedCode import module
in your function app.__init__.py
file does not exist in your function trigger, add one into the folder to make it a Python package, and you can test and treat this function trigger as a normal function package.Attachment
NextSuggestedFolderStructure.zip
PR information
Quality of Code and Contribution Guidelines