diff --git a/src/ASSIGNMENT-02/.devcontainer/Dockerfile b/src/ASSIGNMENT-02/.devcontainer/Dockerfile new file mode 100644 index 0000000..39fe586 --- /dev/null +++ b/src/ASSIGNMENT-02/.devcontainer/Dockerfile @@ -0,0 +1,3 @@ +# Find the Dockerfile at this URL +# https://github.com/Azure/azure-functions-docker/blob/dev/host/4/bullseye/amd64/python/python39/python39-core-tools.Dockerfile +FROM mcr.microsoft.com/azure-functions/python:4-python3.9-core-tools diff --git a/src/ASSIGNMENT-02/.devcontainer/devcontainer.json b/src/ASSIGNMENT-02/.devcontainer/devcontainer.json new file mode 100644 index 0000000..772ab3d --- /dev/null +++ b/src/ASSIGNMENT-02/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "Azure Functions & Python 3", + "dockerFile": "Dockerfile", + "forwardPorts": [ 7071 ], + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-azuretools.vscode-azurefunctions", + "ms-azuretools.vscode-docker", + "ms-python.python" + ] + } + }, + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "npm install", + + // Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/src/ASSIGNMENT-02/.funcignore b/src/ASSIGNMENT-02/.funcignore new file mode 100644 index 0000000..9966315 --- /dev/null +++ b/src/ASSIGNMENT-02/.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/src/ASSIGNMENT-02/.gitignore b/src/ASSIGNMENT-02/.gitignore new file mode 100644 index 0000000..7685fc4 --- /dev/null +++ b/src/ASSIGNMENT-02/.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/src/ASSIGNMENT-02/.npmignore b/src/ASSIGNMENT-02/.npmignore new file mode 100644 index 0000000..e4ebfc7 --- /dev/null +++ b/src/ASSIGNMENT-02/.npmignore @@ -0,0 +1,5 @@ +README.md +test-project +definition-manifest.json +.vscode +.npmignore diff --git a/src/ASSIGNMENT-02/__init__.py b/src/ASSIGNMENT-02/__init__.py new file mode 100644 index 0000000..2a01653 --- /dev/null +++ b/src/ASSIGNMENT-02/__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/src/ASSIGNMENT-02/assignment-func/__init__.py b/src/ASSIGNMENT-02/assignment-func/__init__.py new file mode 100644 index 0000000..2a01653 --- /dev/null +++ b/src/ASSIGNMENT-02/assignment-func/__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/src/ASSIGNMENT-02/assignment-func/function.json b/src/ASSIGNMENT-02/assignment-func/function.json new file mode 100644 index 0000000..d901965 --- /dev/null +++ b/src/ASSIGNMENT-02/assignment-func/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/src/ASSIGNMENT-02/assignment-func/sample.dat b/src/ASSIGNMENT-02/assignment-func/sample.dat new file mode 100644 index 0000000..26aac46 --- /dev/null +++ b/src/ASSIGNMENT-02/assignment-func/sample.dat @@ -0,0 +1,3 @@ +{ + "name": "Azure" +} \ No newline at end of file diff --git a/src/ASSIGNMENT-02/function.json b/src/ASSIGNMENT-02/function.json new file mode 100644 index 0000000..d901965 --- /dev/null +++ b/src/ASSIGNMENT-02/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/src/ASSIGNMENT-02/host.json b/src/ASSIGNMENT-02/host.json new file mode 100644 index 0000000..fd4bee7 --- /dev/null +++ b/src/ASSIGNMENT-02/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/src/ASSIGNMENT-02/sample.dat b/src/ASSIGNMENT-02/sample.dat new file mode 100644 index 0000000..26aac46 --- /dev/null +++ b/src/ASSIGNMENT-02/sample.dat @@ -0,0 +1,3 @@ +{ + "name": "Azure" +} \ No newline at end of file