diff --git a/community/boilerplates/event-triggers/azure-functions/python/echo/.funcignore b/community/boilerplates/event-triggers/azure-functions/python/echo/.funcignore new file mode 100644 index 0000000000000..fa6cc3f80ee41 --- /dev/null +++ b/community/boilerplates/event-triggers/azure-functions/python/echo/.funcignore @@ -0,0 +1,4 @@ +.git* +.vscode +local.settings.json +test \ No newline at end of file diff --git a/community/boilerplates/event-triggers/azure-functions/python/echo/.gitignore b/community/boilerplates/event-triggers/azure-functions/python/echo/.gitignore new file mode 100644 index 0000000000000..3e4bf64199b9e --- /dev/null +++ b/community/boilerplates/event-triggers/azure-functions/python/echo/.gitignore @@ -0,0 +1,135 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don’t work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# Azure Functions artifacts +bin +obj +appsettings.json +local.settings.json + +# Azurite artifacts +__blobstorage__ +__queuestorage__ +__azurite_db*__.json +.python_packages \ No newline at end of file diff --git a/community/boilerplates/event-triggers/azure-functions/python/echo/EchoHttpTrigger/__init__.py b/community/boilerplates/event-triggers/azure-functions/python/echo/EchoHttpTrigger/__init__.py new file mode 100644 index 0000000000000..a4428f95a3d24 --- /dev/null +++ b/community/boilerplates/event-triggers/azure-functions/python/echo/EchoHttpTrigger/__init__.py @@ -0,0 +1,11 @@ +import logging + +import azure.functions as func + +def main(req: func.HttpRequest) -> func.HttpResponse: + logging.info('Python HTTP trigger function processed a request.') + + if(req.body!=NULL): + return func.HttpResponse(req.body) + else: + return func.HttpResponse(status_code=400, body="No request body") \ No newline at end of file diff --git a/community/boilerplates/event-triggers/azure-functions/python/echo/EchoHttpTrigger/function.json b/community/boilerplates/event-triggers/azure-functions/python/echo/EchoHttpTrigger/function.json new file mode 100644 index 0000000000000..d9019652afe1f --- /dev/null +++ b/community/boilerplates/event-triggers/azure-functions/python/echo/EchoHttpTrigger/function.json @@ -0,0 +1,20 @@ +{ + "scriptFile": "__init__.py", + "bindings": [ + { + "authLevel": "function", + "type": "httpTrigger", + "direction": "in", + "name": "req", + "methods": [ + "get", + "post" + ] + }, + { + "type": "http", + "direction": "out", + "name": "$return" + } + ] +} \ No newline at end of file diff --git a/community/boilerplates/event-triggers/azure-functions/python/echo/EchoHttpTrigger/sample.dat b/community/boilerplates/event-triggers/azure-functions/python/echo/EchoHttpTrigger/sample.dat new file mode 100644 index 0000000000000..2e6094396cb44 --- /dev/null +++ b/community/boilerplates/event-triggers/azure-functions/python/echo/EchoHttpTrigger/sample.dat @@ -0,0 +1,3 @@ +{ + "name": "Azure" +} \ No newline at end of file diff --git a/community/boilerplates/event-triggers/azure-functions/python/echo/README.md b/community/boilerplates/event-triggers/azure-functions/python/echo/README.md new file mode 100644 index 0000000000000..3a67d76afc560 --- /dev/null +++ b/community/boilerplates/event-triggers/azure-functions/python/echo/README.md @@ -0,0 +1,35 @@ +# Setup tables +1. Create table: + +``` +notes: + id: int + note: text +``` + +# Setup Cloud Function +1. Run the following commands to deploy: +```bash +az group create --name 'my-functions-group' --location southindia + +az storage account create --name 'myfunctionsstorage' --location southindia --resource-group 'my-functions-group' --sku Standard_LRS + +az functionapp create --name 'myfunctionsapp' --storage-account 'myfunctionsstorage' --resource-group 'my-functions-group' --consumption-plan-location southindia + +func azure login +func azure subscriptions set 'Free Trial' +func azure functionapp publish 'myfunctionsapp' +``` +2. Set Environment variables `ADMIN_SECRET` and `HGE_ENDPOINT` +3. Add a X-Function-Key header if Authorization level is enabled + +# Running locally +`func host start` + +# Check Logs +`func azure functionapp logstream 'myfunctionsapp'` + +# Add the trigger in Hasura GraphQL +1. In events tab, add a trigger +2. Select all insert, update, delete operations for the trigger. +3. Paste your function URL as the webhook. diff --git a/community/boilerplates/event-triggers/azure-functions/python/echo/host.json b/community/boilerplates/event-triggers/azure-functions/python/echo/host.json new file mode 100644 index 0000000000000..fd4bee790b930 --- /dev/null +++ b/community/boilerplates/event-triggers/azure-functions/python/echo/host.json @@ -0,0 +1,15 @@ +{ + "version": "2.0", + "logging": { + "applicationInsights": { + "samplingSettings": { + "isEnabled": true, + "excludedTypes": "Request" + } + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[3.*, 4.0.0)" + } +} \ No newline at end of file diff --git a/community/boilerplates/event-triggers/azure-functions/python/echo/requirements.txt b/community/boilerplates/event-triggers/azure-functions/python/echo/requirements.txt new file mode 100644 index 0000000000000..bdb8fc593a87e --- /dev/null +++ b/community/boilerplates/event-triggers/azure-functions/python/echo/requirements.txt @@ -0,0 +1,5 @@ +# DO NOT include azure-functions-worker in this file +# The Python Worker is managed by Azure Functions platform +# Manually managing azure-functions-worker may cause unexpected issues + +azure-functions