From a3a92ce4d3f93b1ca3b54e67b2f407bfdd98a23f Mon Sep 17 00:00:00 2001 From: Kevin Reynolds Date: Sun, 28 Apr 2024 09:09:16 -0400 Subject: [PATCH 1/8] more build stuff --- labapp/Dockerfile | 6 ++++- labapp/service_install.sh | 49 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 labapp/service_install.sh diff --git a/labapp/Dockerfile b/labapp/Dockerfile index 21a6d4f..ac1341b 100644 --- a/labapp/Dockerfile +++ b/labapp/Dockerfile @@ -6,4 +6,8 @@ WORKDIR /app COPY app . RUN pip install --no-cache-dir -r requirements.txt -CMD ["python", "./app.py"] \ No newline at end of file +EXPOSE 5000 +ENV FLASK_APP app.py +ENV FLASK_RUN_HOST 0.0.0.0 + +CMD ["flask", "run"] diff --git a/labapp/service_install.sh b/labapp/service_install.sh new file mode 100644 index 0000000..b1d7322 --- /dev/null +++ b/labapp/service_install.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Update apt +sudo DEBIAN_FRONTEND=noninteractive apt-get update --yes + +# Check if Docker is installed, install it if it's not +if ! command -v docker &> /dev/null +then + echo "Docker could not be found, installing..." + sudo apt-get install -y docker.io +fi + +# Enable and start Docker +sudo systemctl enable docker +sudo systemctl start docker + +# Variable Declarations +IMAGE=ghcr.io/f5devcentral/f5xc-lab-mcn-practical/labapp:latest +SERVICE=mcn-practical-labapp.service +CONTAINER=mcn-practical-labapp + +# Create the systemd service file +sudo bash -c "cat > /etc/systemd/system/$SERVICE < Date: Sun, 28 Apr 2024 09:23:06 -0400 Subject: [PATCH 2/8] fix package ref --- labapp/app/app.py | 1 - labapp/service_install.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/labapp/app/app.py b/labapp/app/app.py index 129a15c..3b034d9 100644 --- a/labapp/app/app.py +++ b/labapp/app/app.py @@ -7,7 +7,6 @@ import markdown import validators import os -from dotenv import load_dotenv from ce import get_ce_info, get_ce_state app = Flask(__name__) diff --git a/labapp/service_install.sh b/labapp/service_install.sh index b1d7322..76d42fa 100644 --- a/labapp/service_install.sh +++ b/labapp/service_install.sh @@ -22,7 +22,7 @@ CONTAINER=mcn-practical-labapp # Create the systemd service file sudo bash -c "cat > /etc/systemd/system/$SERVICE < Date: Sun, 28 Apr 2024 09:38:10 -0400 Subject: [PATCH 3/8] add env variable --- labapp/app/app.py | 7 +++---- labapp/service_install.sh | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/labapp/app/app.py b/labapp/app/app.py index 3b034d9..6d7d395 100644 --- a/labapp/app/app.py +++ b/labapp/app/app.py @@ -10,12 +10,11 @@ from ce import get_ce_info, get_ce_state app = Flask(__name__) -app.config['site'] = os.getenv('SITE', None) +app.config['udf'] = os.getenv('UDF', False) info = None -if app.config['site']: +if app.config['udf']: info = get_ce_info() app.config['ce_info'] = info -app.config['ce_info'] = None app.config['base_url'] = "lab-mcn.f5demos.com" app.config['CACHE_TYPE'] = 'SimpleCache' cache = Cache(app) @@ -61,7 +60,7 @@ def setup(): return response return render_template('setup.html', base_url=app.config['base_url']) -@app.route('/ce_state') +@app.route('/_ce_state') @cache.cached(timeout=30) def ce_state(): data = get_ce_state(app.config['ce_info']) diff --git a/labapp/service_install.sh b/labapp/service_install.sh index 76d42fa..6901895 100644 --- a/labapp/service_install.sh +++ b/labapp/service_install.sh @@ -32,7 +32,7 @@ Restart=always ExecStartPre=-/usr/bin/docker stop $IMAGE ExecStartPre=-/usr/bin/docker rm $IMAGE ExecStartPre=/usr/bin/docker pull $IMAGE -ExecStart=/usr/bin/docker run -p 1337:5000 --rm --name $CONTAINER $IMAGE +ExecStart=/usr/bin/docker run -p 1337:5000 -e UDF="True" --rm --name $CONTAINER $IMAGE ExecStop=/usr/bin/docker stop $CONTAINER [Install] From 50d50488cc09ff488453ce34c4794c53532a276e Mon Sep 17 00:00:00 2001 From: Kevin Reynolds Date: Sun, 28 Apr 2024 11:03:49 -0400 Subject: [PATCH 4/8] start Azure deploy --- cloudapp/app.py | 21 ++++-------- cloudapp/azure/__init__.py | 2 +- cloudapp/deploy_reqs.txt | 1 + cloudapp/lamda_handler.py | 6 ---- cloudapp/requirements.txt | 5 +-- cloudapp/templates/pretty_echo.html | 53 ++++++++--------------------- cloudapp/zappa_settings.json | 23 +++++++++++++ 7 files changed, 46 insertions(+), 65 deletions(-) create mode 100644 cloudapp/deploy_reqs.txt delete mode 100644 cloudapp/lamda_handler.py create mode 100644 cloudapp/zappa_settings.json diff --git a/cloudapp/app.py b/cloudapp/app.py index 32b97b4..68189a1 100644 --- a/cloudapp/app.py +++ b/cloudapp/app.py @@ -3,29 +3,20 @@ """ import os import json -from dotenv import load_dotenv from flask import Flask, jsonify, request, render_template app = Flask(__name__) -load_dotenv() +app.config['site'] = os.getenv('SITE', "local") @app.template_filter('to_pretty_json') def to_pretty_json(value): return json.dumps(value, sort_keys=True, indent=4) -@app.route('/') -def index(): - """ - Index page - """ - return jsonify(info='MCN Practical web app') - -@app.route('/echo_raw', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) +@app.route('/raw', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) def echo(): """ Echo the request headers and data """ - env = os.getenv('SITE', 'unknown') headers = dict(request.headers) data = None if request.method in ['POST', 'PUT', 'PATCH', 'DELETE']: @@ -35,16 +26,16 @@ def echo(): print(e) response = { 'request_headers': headers, - 'request_env': env + 'request_env': app.config['site'] } if data: response['request_data'] = data return jsonify(response) +@app.route('/', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) @app.route('/echo', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) def echo_html(): - """ Same as /echo, just prettier""" - env = os.getenv('SITE', 'local') + """ Same as /raw, just prettier""" headers = dict(request.headers) data = None if request.method in ['POST', 'PUT', 'PATCH', 'DELETE']: @@ -56,7 +47,7 @@ def echo_html(): data = request.form.to_dict() except Exception: pass - return render_template('pretty_echo.html', request_env=env, request_headers=headers, request_data=data) + return render_template('pretty_echo.html', request_env=app.config['site'], request_headers=headers, request_data=data) if __name__ == '__main__': app.run(debug=True) diff --git a/cloudapp/azure/__init__.py b/cloudapp/azure/__init__.py index 9895c98..f14fc7a 100644 --- a/cloudapp/azure/__init__.py +++ b/cloudapp/azure/__init__.py @@ -1,5 +1,5 @@ import azure.functions as func # pylint: disable=all -from app import app +from ..app import app def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse: """azure handler""" diff --git a/cloudapp/deploy_reqs.txt b/cloudapp/deploy_reqs.txt new file mode 100644 index 0000000..6c98334 --- /dev/null +++ b/cloudapp/deploy_reqs.txt @@ -0,0 +1 @@ +zappa =~0.59.0 \ No newline at end of file diff --git a/cloudapp/lamda_handler.py b/cloudapp/lamda_handler.py deleted file mode 100644 index a2cd0c3..0000000 --- a/cloudapp/lamda_handler.py +++ /dev/null @@ -1,6 +0,0 @@ -from aws_lambda_wsgi import wsgi_handler -from app import app - -def handler(event, context): - """Lambda handler""" - return wsgi_handler(event, context, app) diff --git a/cloudapp/requirements.txt b/cloudapp/requirements.txt index 7841970..6023567 100644 --- a/cloudapp/requirements.txt +++ b/cloudapp/requirements.txt @@ -1,4 +1 @@ -flask ~=3.0.3 -aws_lambda_wsgi ~=0.0.6 -azure_functions ~=1.19.0 -python_dotenv ~=1.0.1 \ No newline at end of file +flask ~=3.0.3 \ No newline at end of file diff --git a/cloudapp/templates/pretty_echo.html b/cloudapp/templates/pretty_echo.html index 8b76dbd..f385c02 100644 --- a/cloudapp/templates/pretty_echo.html +++ b/cloudapp/templates/pretty_echo.html @@ -3,7 +3,7 @@ - Echo + MCN Practical Cloud App @@ -12,33 +12,39 @@

- + MCN Practical Cloud App

Environment
{% if request_env == 'AWS' %} - + {% elif request_env == 'Azure' %} - + {% else %} - + {% endif %}  {{ request_env }}
@@ -55,39 +61,8 @@

{{ request_data | to_pretty_json }}
-
-
- - -
-

{% endif %}
- diff --git a/cloudapp/zappa_settings.json b/cloudapp/zappa_settings.json new file mode 100644 index 0000000..fb476e9 --- /dev/null +++ b/cloudapp/zappa_settings.json @@ -0,0 +1,23 @@ +{ + "dev": { + "app_function": "app.app", + "exclude": [ + "boto3", + "dateutil", + "botocore", + "s3transfer", + "concurrent", + "azure", + "static", + "deploy_reqs.txt" + ], + "profile_name": "default", + "project_name": "cloudapp", + "runtime": "python3.11", + "s3_bucket": "mcn-prac-cloudapp", + "aws_region": "us-east-1", + "environment_variables": { + "SITE": "AWS" + } + } +} \ No newline at end of file From da4d0472b2707b6e08867802b247c3ff6f92327b Mon Sep 17 00:00:00 2001 From: Kevin Reynolds Date: Sun, 28 Apr 2024 11:13:45 -0400 Subject: [PATCH 5/8] working on azure deploy --- cloudapp/app.py | 86 ++++++++++++++++++++------------------ cloudapp/azure/__init__.py | 8 ++-- 2 files changed, 50 insertions(+), 44 deletions(-) diff --git a/cloudapp/app.py b/cloudapp/app.py index 68189a1..df92ab0 100644 --- a/cloudapp/app.py +++ b/cloudapp/app.py @@ -5,49 +5,53 @@ import json from flask import Flask, jsonify, request, render_template -app = Flask(__name__) -app.config['site'] = os.getenv('SITE', "local") +def create_app(): + app = Flask(__name__) + app.config['site'] = os.getenv('SITE', "local") -@app.template_filter('to_pretty_json') -def to_pretty_json(value): - return json.dumps(value, sort_keys=True, indent=4) + @app.template_filter('to_pretty_json') + def to_pretty_json(value): + return json.dumps(value, sort_keys=True, indent=4) -@app.route('/raw', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) -def echo(): - """ - Echo the request headers and data - """ - headers = dict(request.headers) - data = None - if request.method in ['POST', 'PUT', 'PATCH', 'DELETE']: - try: - data = request.get_json() or request.form.to_dict() - except Exception as e: - print(e) - response = { - 'request_headers': headers, - 'request_env': app.config['site'] - } - if data: - response['request_data'] = data - return jsonify(response) + @app.route('/raw', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) + def echo(): + """ + Echo the request headers and data + """ + headers = dict(request.headers) + data = None + if request.method in ['POST', 'PUT', 'PATCH', 'DELETE']: + try: + data = request.get_json() or request.form.to_dict() + except Exception as e: + print(e) + response = { + 'request_headers': headers, + 'request_env': app.config['site'] + } + if data: + response['request_data'] = data + return jsonify(response) -@app.route('/', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) -@app.route('/echo', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) -def echo_html(): - """ Same as /raw, just prettier""" - headers = dict(request.headers) - data = None - if request.method in ['POST', 'PUT', 'PATCH', 'DELETE']: - try: - data = request.get_json() - except Exception: - pass - try: - data = request.form.to_dict() - except Exception: - pass - return render_template('pretty_echo.html', request_env=app.config['site'], request_headers=headers, request_data=data) + @app.route('/', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) + @app.route('/echo', methods=['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) + def echo_html(): + """ Same as /raw, just prettier""" + headers = dict(request.headers) + data = None + if request.method in ['POST', 'PUT', 'PATCH', 'DELETE']: + try: + data = request.get_json() + except Exception: + pass + try: + data = request.form.to_dict() + except Exception: + pass + return render_template('pretty_echo.html', request_env=app.config['site'], request_headers=headers, request_data=data) + + return app +app = create_app() if __name__ == '__main__': - app.run(debug=True) + app.run(debug=False) diff --git a/cloudapp/azure/__init__.py b/cloudapp/azure/__init__.py index f14fc7a..0ddd935 100644 --- a/cloudapp/azure/__init__.py +++ b/cloudapp/azure/__init__.py @@ -1,6 +1,8 @@ import azure.functions as func # pylint: disable=all -from ..app import app +from ..app import create_app -def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse: +app = create_app() + +def main(req: func.HttpRequest) -> func.HttpResponse: """azure handler""" - return func.WsgiMiddleware(app.wsgi_app).handle(req, context) + return func.WsgiMiddleware(app.wsgi_app).handle(req) From 1aa0134c821f2d5f9b13f3dfb7322047669a9fbb Mon Sep 17 00:00:00 2001 From: Kevin Reynolds Date: Sun, 28 Apr 2024 11:33:05 -0400 Subject: [PATCH 6/8] action for azure --- .github/workflows/cloudapp-azure.yml | 51 +++++++++++++++++++ .../{lab-build.yml => labapp-build.yml} | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cloudapp-azure.yml rename .github/workflows/{lab-build.yml => labapp-build.yml} (98%) diff --git a/.github/workflows/cloudapp-azure.yml b/.github/workflows/cloudapp-azure.yml new file mode 100644 index 0000000..f956cdd --- /dev/null +++ b/.github/workflows/cloudapp-azure.yml @@ -0,0 +1,51 @@ +name: CloudApp Azure Deploy + +on: + workflow_dispatch: + push: + branches: + - 'dev' + - 'main' + paths: + - cloudapp/azure/** + - cloudapp/app.py + - cloudapp/templates/** + tags: + - 'v*' + pull_request: + branches: + - 'dev' + paths: + - cloudapp/azure/** + - cloudapp/app.py + - cloudapp/templates/** + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Login to Azure + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Deploy to Azure Functions + uses: azure/functions-action@v1 + with: + app-name: YourFunctionAppName + package: ./cloudapp + publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }} + diff --git a/.github/workflows/lab-build.yml b/.github/workflows/labapp-build.yml similarity index 98% rename from .github/workflows/lab-build.yml rename to .github/workflows/labapp-build.yml index 7a4fcac..35d2567 100644 --- a/.github/workflows/lab-build.yml +++ b/.github/workflows/labapp-build.yml @@ -1,4 +1,4 @@ -name: lab-build +name: LabApp Build on: workflow_dispatch: From 53394c8db71112f2057e9459cd776103d30733a1 Mon Sep 17 00:00:00 2001 From: Kevin Reynolds Date: Sun, 28 Apr 2024 14:28:26 -0400 Subject: [PATCH 7/8] true up on failed function --- .DS_Store | Bin 6148 -> 6148 bytes .vscode/extensions.json | 6 + .vscode/launch.json | 15 ++ .vscode/settings.json | 10 ++ .vscode/tasks.json | 33 +++++ cloudapp/__init__.py | 0 cloudapp/app.py | 1 + cloudapp/azure/.funcignore | 8 ++ cloudapp/azure/.gitignore | 135 ++++++++++++++++++ .../azure/MCN-Practical-Azure/__init__.py | 24 ++++ .../azure/MCN-Practical-Azure/function.json | 20 +++ cloudapp/azure/MCN-Practical-Azure/sample.dat | 3 + cloudapp/azure/function.json | 24 ++++ cloudapp/azure/function_app.py | 25 ++++ cloudapp/azure/host.json | 15 ++ .../azure/mcn-practical-cloudapp/__init__.py | 24 ++++ .../mcn-practical-cloudapp/function.json | 20 +++ .../azure/mcn-practical-cloudapp/sample.dat | 3 + cloudapp/azure/requirements.txt | 5 + cloudapp/azure_func/function_app.py | 31 ++++ cloudapp/azure_func/host.json | 22 +++ cloudapp/azure_func/requirements.txt | 2 + cloudapp/zappa_settings.json | 1 + 23 files changed, 427 insertions(+) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 cloudapp/__init__.py create mode 100644 cloudapp/azure/.funcignore create mode 100644 cloudapp/azure/.gitignore create mode 100644 cloudapp/azure/MCN-Practical-Azure/__init__.py create mode 100644 cloudapp/azure/MCN-Practical-Azure/function.json create mode 100644 cloudapp/azure/MCN-Practical-Azure/sample.dat create mode 100644 cloudapp/azure/function.json create mode 100644 cloudapp/azure/function_app.py create mode 100644 cloudapp/azure/host.json create mode 100644 cloudapp/azure/mcn-practical-cloudapp/__init__.py create mode 100644 cloudapp/azure/mcn-practical-cloudapp/function.json create mode 100644 cloudapp/azure/mcn-practical-cloudapp/sample.dat create mode 100644 cloudapp/azure/requirements.txt create mode 100644 cloudapp/azure_func/function_app.py create mode 100644 cloudapp/azure_func/host.json create mode 100644 cloudapp/azure_func/requirements.txt diff --git a/.DS_Store b/.DS_Store index 0c2bd139f2d1ee82227a855c1f9ce1a7be4ee97f..d0a115c62ebef5e615aad8ddfb34c5d6e1b3d03a 100644 GIT binary patch delta 109 zcmZoMXfc=|#>B)qu~2NHo}wr-0|Nsi1A_nqLkdG8LjglUT1s*9W=5vvjB+3;4u)ig x9EN;`Qe^3*{QMlo%{+|vSU0nC@N)nS18VrrJegm_k^^WK5HT=p4iMSG3;^It7OnsQ delta 84 zcmZoMXfc=|#>B`mu~2NHo}wrd0|Nsi1A_nqLjglUQh9MfQcix-#KPs14MbQr>oDDB l-Pj<@xS5@Up9838vm*0%=E?jbmK;D`AZ<*W14Onk0{~xL6NUf) diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..3f63eb9 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "ms-azuretools.vscode-azurefunctions", + "ms-python.python" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9a24428 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Python Functions", + "type": "debugpy", + "request": "attach", + "connect": { + "host": "localhost", + "port": 9091 + }, + "preLaunchTask": "func: host start" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1a5cba6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "azureFunctions.deploySubpath": "cloudapp/azure_function", + "azureFunctions.scmDoBuildDuringDeployment": true, + "azureFunctions.pythonVenv": ".venv", + "azureFunctions.projectLanguage": "Python", + "azureFunctions.projectRuntime": "~4", + "debug.internalConsoleOptions": "neverOpen", + "azureFunctions.projectSubpath": "cloudapp/azure_function", + "azureFunctions.projectLanguageModel": 2 +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..dca599e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,33 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "func", + "label": "func: host start", + "command": "host start", + "problemMatcher": "$func-python-watch", + "isBackground": true, + "dependsOn": "pip install (functions)", + "options": { + "cwd": "${workspaceFolder}/cloudapp/azure_function" + } + }, + { + "label": "pip install (functions)", + "type": "shell", + "osx": { + "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" + }, + "windows": { + "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt" + }, + "linux": { + "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" + }, + "problemMatcher": [], + "options": { + "cwd": "${workspaceFolder}/cloudapp/azure_function" + } + } + ] +} \ No newline at end of file diff --git a/cloudapp/__init__.py b/cloudapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cloudapp/app.py b/cloudapp/app.py index df92ab0..a5d7a7b 100644 --- a/cloudapp/app.py +++ b/cloudapp/app.py @@ -53,5 +53,6 @@ def echo_html(): return app app = create_app() + if __name__ == '__main__': app.run(debug=False) diff --git a/cloudapp/azure/.funcignore b/cloudapp/azure/.funcignore new file mode 100644 index 0000000..9966315 --- /dev/null +++ b/cloudapp/azure/.funcignore @@ -0,0 +1,8 @@ +.git* +.vscode +__azurite_db*__.json +__blobstorage__ +__queuestorage__ +local.settings.json +test +.venv \ No newline at end of file diff --git a/cloudapp/azure/.gitignore b/cloudapp/azure/.gitignore new file mode 100644 index 0000000..7685fc4 --- /dev/null +++ b/cloudapp/azure/.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/cloudapp/azure/MCN-Practical-Azure/__init__.py b/cloudapp/azure/MCN-Practical-Azure/__init__.py new file mode 100644 index 0000000..b85edf6 --- /dev/null +++ b/cloudapp/azure/MCN-Practical-Azure/__init__.py @@ -0,0 +1,24 @@ +import logging + +import azure.functions as func + + +def main(req: func.HttpRequest) -> func.HttpResponse: + logging.info('Python HTTP trigger function processed a request.') + + name = req.params.get('name') + if not name: + try: + req_body = req.get_json() + except ValueError: + pass + else: + name = req_body.get('name') + + if name: + return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.") + else: + return func.HttpResponse( + "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.", + status_code=200 + ) diff --git a/cloudapp/azure/MCN-Practical-Azure/function.json b/cloudapp/azure/MCN-Practical-Azure/function.json new file mode 100644 index 0000000..d901965 --- /dev/null +++ b/cloudapp/azure/MCN-Practical-Azure/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/cloudapp/azure/MCN-Practical-Azure/sample.dat b/cloudapp/azure/MCN-Practical-Azure/sample.dat new file mode 100644 index 0000000..2e60943 --- /dev/null +++ b/cloudapp/azure/MCN-Practical-Azure/sample.dat @@ -0,0 +1,3 @@ +{ + "name": "Azure" +} \ No newline at end of file diff --git a/cloudapp/azure/function.json b/cloudapp/azure/function.json new file mode 100644 index 0000000..65f2ea5 --- /dev/null +++ b/cloudapp/azure/function.json @@ -0,0 +1,24 @@ +{ + "scriptFile": "__init__.py", + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "req", + "methods": [ + "get", + "post", + "put", + "patch", + "delete" + ], + "route": "/{*route}" + }, + { + "type": "http", + "direction": "out", + "name": "$return" + } + ] +} \ No newline at end of file diff --git a/cloudapp/azure/function_app.py b/cloudapp/azure/function_app.py new file mode 100644 index 0000000..9ce7e44 --- /dev/null +++ b/cloudapp/azure/function_app.py @@ -0,0 +1,25 @@ +import azure.functions as func +import logging + +app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) + +@app.route(route="mcn_prac_cloudapp") +def mcn_prac_cloudapp(req: func.HttpRequest) -> func.HttpResponse: + logging.info('Python HTTP trigger function processed a request.') + + name = req.params.get('name') + if not name: + try: + req_body = req.get_json() + except ValueError: + pass + else: + name = req_body.get('name') + + if name: + return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.") + else: + return func.HttpResponse( + "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.", + status_code=200 + ) \ No newline at end of file diff --git a/cloudapp/azure/host.json b/cloudapp/azure/host.json new file mode 100644 index 0000000..9df9136 --- /dev/null +++ b/cloudapp/azure/host.json @@ -0,0 +1,15 @@ +{ + "version": "2.0", + "logging": { + "applicationInsights": { + "samplingSettings": { + "isEnabled": true, + "excludedTypes": "Request" + } + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[4.*, 5.0.0)" + } +} \ No newline at end of file diff --git a/cloudapp/azure/mcn-practical-cloudapp/__init__.py b/cloudapp/azure/mcn-practical-cloudapp/__init__.py new file mode 100644 index 0000000..b85edf6 --- /dev/null +++ b/cloudapp/azure/mcn-practical-cloudapp/__init__.py @@ -0,0 +1,24 @@ +import logging + +import azure.functions as func + + +def main(req: func.HttpRequest) -> func.HttpResponse: + logging.info('Python HTTP trigger function processed a request.') + + name = req.params.get('name') + if not name: + try: + req_body = req.get_json() + except ValueError: + pass + else: + name = req_body.get('name') + + if name: + return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.") + else: + return func.HttpResponse( + "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.", + status_code=200 + ) diff --git a/cloudapp/azure/mcn-practical-cloudapp/function.json b/cloudapp/azure/mcn-practical-cloudapp/function.json new file mode 100644 index 0000000..d901965 --- /dev/null +++ b/cloudapp/azure/mcn-practical-cloudapp/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/cloudapp/azure/mcn-practical-cloudapp/sample.dat b/cloudapp/azure/mcn-practical-cloudapp/sample.dat new file mode 100644 index 0000000..2e60943 --- /dev/null +++ b/cloudapp/azure/mcn-practical-cloudapp/sample.dat @@ -0,0 +1,3 @@ +{ + "name": "Azure" +} \ No newline at end of file diff --git a/cloudapp/azure/requirements.txt b/cloudapp/azure/requirements.txt new file mode 100644 index 0000000..bdb8fc5 --- /dev/null +++ b/cloudapp/azure/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 diff --git a/cloudapp/azure_func/function_app.py b/cloudapp/azure_func/function_app.py new file mode 100644 index 0000000..6cef628 --- /dev/null +++ b/cloudapp/azure_func/function_app.py @@ -0,0 +1,31 @@ +import logging +import azure.functions as func +import sys +sys.path.append('..') +from app import create_app + +flask = create_app() + +app = func.WsgiFunctionApp(app=flask.wsgi_app, http_auth_level=func.AuthLevel.ANONYMOUS) + + +@app.route(route="cloudapp_dev", auth_level=func.AuthLevel.ANONYMOUS) +def cloudapp_dev(req: func.HttpRequest) -> func.HttpResponse: + logging.info('Python HTTP trigger function processed a request.') + + name = req.params.get('name') + if not name: + try: + req_body = req.get_json() + except ValueError: + pass + else: + name = req_body.get('name') + + if name: + return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.") + else: + return func.HttpResponse( + "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.", + status_code=200 + ) \ No newline at end of file diff --git a/cloudapp/azure_func/host.json b/cloudapp/azure_func/host.json new file mode 100644 index 0000000..fc01b3b --- /dev/null +++ b/cloudapp/azure_func/host.json @@ -0,0 +1,22 @@ +{ + "version": "2.0", + "logging": { + "applicationInsights": { + "samplingSettings": { + "isEnabled": true, + "excludedTypes": "Request" + } + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[3.*, 4.0.0)" + }, + "extensions": + { + "http": + { + "routePrefix": "" + } + } + } \ No newline at end of file diff --git a/cloudapp/azure_func/requirements.txt b/cloudapp/azure_func/requirements.txt new file mode 100644 index 0000000..b2b52b4 --- /dev/null +++ b/cloudapp/azure_func/requirements.txt @@ -0,0 +1,2 @@ +azure-functions +flask \ No newline at end of file diff --git a/cloudapp/zappa_settings.json b/cloudapp/zappa_settings.json index fb476e9..92d6eea 100644 --- a/cloudapp/zappa_settings.json +++ b/cloudapp/zappa_settings.json @@ -8,6 +8,7 @@ "s3transfer", "concurrent", "azure", + "azure_function", "static", "deploy_reqs.txt" ], From 4a7db83d67426a683fbcc280e8848b748ce6dfe7 Mon Sep 17 00:00:00 2001 From: Kevin Reynolds Date: Sun, 28 Apr 2024 14:39:37 -0400 Subject: [PATCH 8/8] fix links later --- .github/workflows/cloudapp-azure.yml | 51 ------- .github/workflows/cloudapp-build.yml | 59 ++++++++ cloudapp/.dockerignore | 10 ++ cloudapp/Dockerfile | 13 ++ cloudapp/__init__.py | 0 cloudapp/{ => app}/app.py | 0 cloudapp/{ => app}/requirements.txt | 0 cloudapp/{ => app}/static/aws.png | Bin cloudapp/{ => app}/static/azure.png | Bin cloudapp/{ => app}/static/flask.png | Bin cloudapp/{ => app}/static/logo.png | Bin cloudapp/{ => app}/templates/pretty_echo.html | 0 cloudapp/{ => app}/zappa_settings.json | 6 +- cloudapp/azure/.funcignore | 8 -- cloudapp/azure/.gitignore | 135 ------------------ .../azure/MCN-Practical-Azure/__init__.py | 24 ---- .../azure/MCN-Practical-Azure/function.json | 20 --- cloudapp/azure/MCN-Practical-Azure/sample.dat | 3 - cloudapp/azure/__init__.py | 8 -- cloudapp/azure/function.json | 24 ---- cloudapp/azure/function_app.py | 25 ---- cloudapp/azure/host.json | 15 -- .../azure/mcn-practical-cloudapp/__init__.py | 24 ---- .../mcn-practical-cloudapp/function.json | 20 --- .../azure/mcn-practical-cloudapp/sample.dat | 3 - cloudapp/azure/requirements.txt | 5 - 26 files changed, 83 insertions(+), 370 deletions(-) delete mode 100644 .github/workflows/cloudapp-azure.yml create mode 100644 .github/workflows/cloudapp-build.yml create mode 100644 cloudapp/.dockerignore create mode 100644 cloudapp/Dockerfile delete mode 100644 cloudapp/__init__.py rename cloudapp/{ => app}/app.py (100%) rename cloudapp/{ => app}/requirements.txt (100%) rename cloudapp/{ => app}/static/aws.png (100%) rename cloudapp/{ => app}/static/azure.png (100%) rename cloudapp/{ => app}/static/flask.png (100%) rename cloudapp/{ => app}/static/logo.png (100%) rename cloudapp/{ => app}/templates/pretty_echo.html (100%) rename cloudapp/{ => app}/zappa_settings.json (77%) delete mode 100644 cloudapp/azure/.funcignore delete mode 100644 cloudapp/azure/.gitignore delete mode 100644 cloudapp/azure/MCN-Practical-Azure/__init__.py delete mode 100644 cloudapp/azure/MCN-Practical-Azure/function.json delete mode 100644 cloudapp/azure/MCN-Practical-Azure/sample.dat delete mode 100644 cloudapp/azure/__init__.py delete mode 100644 cloudapp/azure/function.json delete mode 100644 cloudapp/azure/function_app.py delete mode 100644 cloudapp/azure/host.json delete mode 100644 cloudapp/azure/mcn-practical-cloudapp/__init__.py delete mode 100644 cloudapp/azure/mcn-practical-cloudapp/function.json delete mode 100644 cloudapp/azure/mcn-practical-cloudapp/sample.dat delete mode 100644 cloudapp/azure/requirements.txt diff --git a/.github/workflows/cloudapp-azure.yml b/.github/workflows/cloudapp-azure.yml deleted file mode 100644 index f956cdd..0000000 --- a/.github/workflows/cloudapp-azure.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: CloudApp Azure Deploy - -on: - workflow_dispatch: - push: - branches: - - 'dev' - - 'main' - paths: - - cloudapp/azure/** - - cloudapp/app.py - - cloudapp/templates/** - tags: - - 'v*' - pull_request: - branches: - - 'dev' - paths: - - cloudapp/azure/** - - cloudapp/app.py - - cloudapp/templates/** - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Login to Azure - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - - name: Deploy to Azure Functions - uses: azure/functions-action@v1 - with: - app-name: YourFunctionAppName - package: ./cloudapp - publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }} - diff --git a/.github/workflows/cloudapp-build.yml b/.github/workflows/cloudapp-build.yml new file mode 100644 index 0000000..2a3c7fd --- /dev/null +++ b/.github/workflows/cloudapp-build.yml @@ -0,0 +1,59 @@ +name: CloudApp Build + +on: + workflow_dispatch: + push: + branches: + - 'dev' + - 'main' + paths: + - cloudapp/** + tags: + - 'v*' + pull_request: + branches: + - 'dev' + paths: + - cloudapp/** +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}/cloudapp + CONTEXT: cloudapp +jobs: + docker: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} + - + name: Login to Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v5 + with: + context: "{{defaultContext}}:${{env.CONTEXT}}" + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/cloudapp/.dockerignore b/cloudapp/.dockerignore new file mode 100644 index 0000000..49786c5 --- /dev/null +++ b/cloudapp/.dockerignore @@ -0,0 +1,10 @@ +.git +.gitignore +Dockerfile* +docker-compose* +README.md +LICENSE +SUPPORT.md +.vscode +.github +zappa_settings.json \ No newline at end of file diff --git a/cloudapp/Dockerfile b/cloudapp/Dockerfile new file mode 100644 index 0000000..49b6a8f --- /dev/null +++ b/cloudapp/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.10.14-slim +LABEL org.opencontainers.image.description MCN Practical Cloud App + +ENV PYTHONUNBUFFERED=1 +WORKDIR /app +COPY app . +RUN pip install --no-cache-dir -r requirements.txt + +EXPOSE 5000 +ENV FLASK_APP app.py +ENV FLASK_RUN_HOST 0.0.0.0 + +CMD ["flask", "run"] diff --git a/cloudapp/__init__.py b/cloudapp/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/cloudapp/app.py b/cloudapp/app/app.py similarity index 100% rename from cloudapp/app.py rename to cloudapp/app/app.py diff --git a/cloudapp/requirements.txt b/cloudapp/app/requirements.txt similarity index 100% rename from cloudapp/requirements.txt rename to cloudapp/app/requirements.txt diff --git a/cloudapp/static/aws.png b/cloudapp/app/static/aws.png similarity index 100% rename from cloudapp/static/aws.png rename to cloudapp/app/static/aws.png diff --git a/cloudapp/static/azure.png b/cloudapp/app/static/azure.png similarity index 100% rename from cloudapp/static/azure.png rename to cloudapp/app/static/azure.png diff --git a/cloudapp/static/flask.png b/cloudapp/app/static/flask.png similarity index 100% rename from cloudapp/static/flask.png rename to cloudapp/app/static/flask.png diff --git a/cloudapp/static/logo.png b/cloudapp/app/static/logo.png similarity index 100% rename from cloudapp/static/logo.png rename to cloudapp/app/static/logo.png diff --git a/cloudapp/templates/pretty_echo.html b/cloudapp/app/templates/pretty_echo.html similarity index 100% rename from cloudapp/templates/pretty_echo.html rename to cloudapp/app/templates/pretty_echo.html diff --git a/cloudapp/zappa_settings.json b/cloudapp/app/zappa_settings.json similarity index 77% rename from cloudapp/zappa_settings.json rename to cloudapp/app/zappa_settings.json index 92d6eea..7c4cb4f 100644 --- a/cloudapp/zappa_settings.json +++ b/cloudapp/app/zappa_settings.json @@ -6,11 +6,7 @@ "dateutil", "botocore", "s3transfer", - "concurrent", - "azure", - "azure_function", - "static", - "deploy_reqs.txt" + "concurrent" ], "profile_name": "default", "project_name": "cloudapp", diff --git a/cloudapp/azure/.funcignore b/cloudapp/azure/.funcignore deleted file mode 100644 index 9966315..0000000 --- a/cloudapp/azure/.funcignore +++ /dev/null @@ -1,8 +0,0 @@ -.git* -.vscode -__azurite_db*__.json -__blobstorage__ -__queuestorage__ -local.settings.json -test -.venv \ No newline at end of file diff --git a/cloudapp/azure/.gitignore b/cloudapp/azure/.gitignore deleted file mode 100644 index 7685fc4..0000000 --- a/cloudapp/azure/.gitignore +++ /dev/null @@ -1,135 +0,0 @@ -# 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/cloudapp/azure/MCN-Practical-Azure/__init__.py b/cloudapp/azure/MCN-Practical-Azure/__init__.py deleted file mode 100644 index b85edf6..0000000 --- a/cloudapp/azure/MCN-Practical-Azure/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -import logging - -import azure.functions as func - - -def main(req: func.HttpRequest) -> func.HttpResponse: - logging.info('Python HTTP trigger function processed a request.') - - name = req.params.get('name') - if not name: - try: - req_body = req.get_json() - except ValueError: - pass - else: - name = req_body.get('name') - - if name: - return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.") - else: - return func.HttpResponse( - "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.", - status_code=200 - ) diff --git a/cloudapp/azure/MCN-Practical-Azure/function.json b/cloudapp/azure/MCN-Practical-Azure/function.json deleted file mode 100644 index d901965..0000000 --- a/cloudapp/azure/MCN-Practical-Azure/function.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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/cloudapp/azure/MCN-Practical-Azure/sample.dat b/cloudapp/azure/MCN-Practical-Azure/sample.dat deleted file mode 100644 index 2e60943..0000000 --- a/cloudapp/azure/MCN-Practical-Azure/sample.dat +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "Azure" -} \ No newline at end of file diff --git a/cloudapp/azure/__init__.py b/cloudapp/azure/__init__.py deleted file mode 100644 index 0ddd935..0000000 --- a/cloudapp/azure/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -import azure.functions as func # pylint: disable=all -from ..app import create_app - -app = create_app() - -def main(req: func.HttpRequest) -> func.HttpResponse: - """azure handler""" - return func.WsgiMiddleware(app.wsgi_app).handle(req) diff --git a/cloudapp/azure/function.json b/cloudapp/azure/function.json deleted file mode 100644 index 65f2ea5..0000000 --- a/cloudapp/azure/function.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "scriptFile": "__init__.py", - "bindings": [ - { - "authLevel": "anonymous", - "type": "httpTrigger", - "direction": "in", - "name": "req", - "methods": [ - "get", - "post", - "put", - "patch", - "delete" - ], - "route": "/{*route}" - }, - { - "type": "http", - "direction": "out", - "name": "$return" - } - ] -} \ No newline at end of file diff --git a/cloudapp/azure/function_app.py b/cloudapp/azure/function_app.py deleted file mode 100644 index 9ce7e44..0000000 --- a/cloudapp/azure/function_app.py +++ /dev/null @@ -1,25 +0,0 @@ -import azure.functions as func -import logging - -app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) - -@app.route(route="mcn_prac_cloudapp") -def mcn_prac_cloudapp(req: func.HttpRequest) -> func.HttpResponse: - logging.info('Python HTTP trigger function processed a request.') - - name = req.params.get('name') - if not name: - try: - req_body = req.get_json() - except ValueError: - pass - else: - name = req_body.get('name') - - if name: - return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.") - else: - return func.HttpResponse( - "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.", - status_code=200 - ) \ No newline at end of file diff --git a/cloudapp/azure/host.json b/cloudapp/azure/host.json deleted file mode 100644 index 9df9136..0000000 --- a/cloudapp/azure/host.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "2.0", - "logging": { - "applicationInsights": { - "samplingSettings": { - "isEnabled": true, - "excludedTypes": "Request" - } - } - }, - "extensionBundle": { - "id": "Microsoft.Azure.Functions.ExtensionBundle", - "version": "[4.*, 5.0.0)" - } -} \ No newline at end of file diff --git a/cloudapp/azure/mcn-practical-cloudapp/__init__.py b/cloudapp/azure/mcn-practical-cloudapp/__init__.py deleted file mode 100644 index b85edf6..0000000 --- a/cloudapp/azure/mcn-practical-cloudapp/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -import logging - -import azure.functions as func - - -def main(req: func.HttpRequest) -> func.HttpResponse: - logging.info('Python HTTP trigger function processed a request.') - - name = req.params.get('name') - if not name: - try: - req_body = req.get_json() - except ValueError: - pass - else: - name = req_body.get('name') - - if name: - return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.") - else: - return func.HttpResponse( - "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.", - status_code=200 - ) diff --git a/cloudapp/azure/mcn-practical-cloudapp/function.json b/cloudapp/azure/mcn-practical-cloudapp/function.json deleted file mode 100644 index d901965..0000000 --- a/cloudapp/azure/mcn-practical-cloudapp/function.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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/cloudapp/azure/mcn-practical-cloudapp/sample.dat b/cloudapp/azure/mcn-practical-cloudapp/sample.dat deleted file mode 100644 index 2e60943..0000000 --- a/cloudapp/azure/mcn-practical-cloudapp/sample.dat +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "Azure" -} \ No newline at end of file diff --git a/cloudapp/azure/requirements.txt b/cloudapp/azure/requirements.txt deleted file mode 100644 index bdb8fc5..0000000 --- a/cloudapp/azure/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -# 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