Skip to content

How to manage shared code #1987

@NVolcz

Description

@NVolcz

I have a bunch of Azure Python Function Apps that share some code and is not sure how I am sure how this is supposed work. The shared code is proprietary and cannot be uploaded to PyPi. My issue is similar to: Azure/azure-functions-python-worker#219

This is how I would like the folder structure to look like:

AzureFunctions
|_ FunctionApp1
    |_ requirements.txt
    |_ HttpTrigger1
        |_ __init__.py
        |_ function.json
|_FunctionApp2
    |_ requirements.txt
    |_ HttpTrigger1
        |_ __init__.py
        |_ function.json
|_ SharedCode
    |_ setup.py
    |_ requirements.txt
    |_ src
        |_ __init__.py
        |_ common1.py
        |_ common2.py
    |_ tests
        |_ test1.py
        |_ test2.py

I have tried to use the file: protocol in FunctionApp1 and FunctionApp2's requirements.txt:
file:../SharedCode
Most tooling understands this except for pip freeze. Skipping the file: part also seems works well with other tooling but neither does not work well with func. Remote build and --build-native-deps cannot build these function apps since they do not get access to the SharedCode folder, only the functions individual folders. I have therefor tried to build locally. It seems like the first problem with this lies with the packapp script: https://github.com/Azure/azure-functions-core-tools/blob/dev/tools/python/packapp/__main__.py#L73-L79
This SO thread seems related: https://stackoverflow.com/questions/11147667/is-there-a-way-to-list-pip-dependencies-requirements
pip download outputs this:

Processing <PATH>/AzureFunctions/SharedCode
    Link is a directory, ignoring download_dir

What should I do?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions