Home > Net >  file structure and init method for webjob/function using python
file structure and init method for webjob/function using python

Time:10-26

am a beginner in python and wants to test some code in webjob and function app. usually i write code using c# so in visual studio we have templates to create webjob/function app so that we get all required files and init code. Now using python i need the required file structure and init code.

CodePudding user response:

The folder/file structure for a Python Functions project looks like:

<project_root>/
 | - .venv/
 | - .vscode/
 | - my_first_function/
 | | - __init__.py
 | | - function.json
 | | - example.py
 | - my_second_function/
 | | - __init__.py
 | | - function.json
 | - shared_code/
 | | - __init__.py
 | | - my_first_helper_function.py
 | | - my_second_helper_function.py
 | - tests/
 | | - test_my_second_function.py
 | - .funcignore
 | - host.json
 | - local.settings.json
 | - requirements.txt
 | - Dockerfile

init method for webjob/function using python

init__.py
import azure.functions as func
import logging


def main(req: func.HttpRequest,
         obj: func.InputStream):
logging.info(f'Python HTTP triggered function processed: {obj.read()}')

Please follow developer guide of Azure functions using python and Python Azure Functions using VS Code.

  • Related