From b4fa6efcba22ebf632d4cb5ad57f1ef0843a8294 Mon Sep 17 00:00:00 2001 From: Steve Laing Date: Thu, 9 Jan 2025 15:38:21 +0000 Subject: [PATCH] Amend function app name (fixup) --- Dockerfile | 24 ------------------- compose.yml | 6 ++--- .../tf-core/environments/development.tfvars | 4 ++-- .../tf-core/environments/integration.tfvars | 4 ++-- .../tf-core/environments/nft.tfvars | 4 ++-- .../tf-core/environments/preprod.tfvars | 4 ++-- .../tf-core/environments/production.tfvars | 4 ++-- infrastructure/tf-core/function_app.tf | 4 +++- src/{notify => notifications-api}/Dockerfile | 0 app.py => src/notifications-api/app.py | 0 .../app/__init__.py | 0 .../app/routes.py | 0 .../notifications-api/function_app.py | 0 host.json => src/notifications-api/host.json | 0 .../local.settings.json | 0 src/notify/app.py | 7 ------ src/notify/function_app.py | 14 ----------- src/notify/host.json | 8 ------- tests/integration/notify/__init__.py | 2 +- tests/unit/notify/__init__.py | 2 +- 20 files changed, 18 insertions(+), 69 deletions(-) delete mode 100644 Dockerfile rename src/{notify => notifications-api}/Dockerfile (100%) rename app.py => src/notifications-api/app.py (100%) rename src/{notify => notifications-api}/app/__init__.py (100%) rename src/{notify => notifications-api}/app/routes.py (100%) rename function_app.py => src/notifications-api/function_app.py (100%) rename host.json => src/notifications-api/host.json (100%) rename src/{notify => notifications-api}/local.settings.json (100%) delete mode 100644 src/notify/app.py delete mode 100644 src/notify/function_app.py delete mode 100644 src/notify/host.json diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 3c4fa336..00000000 --- a/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -# To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/python:4-python3.11-appservice -FROM mcr.microsoft.com/azure-functions/python:4-python3.11 - -ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ - AzureFunctionsJobHost__Logging__Console__IsEnabled=true \ - AzureWebJobsFeatureFlags=EnableWorkerIndexing \ - AzureWebJobsStorage=UseDevelopmentStorage=true \ - APPLICATION_ID=${APPLICATION_ID} \ - DATABASE_HOST=${DATABASE_HOST} \ - DATABASE_USER=${DATABASE_USER} \ - DATABASE_PASSWORD=${DATABASE_PASSWORD} \ - DATABASE_NAME=${DATABASE_NAME} \ - FUNCTIONS_WORKER_RUNTIME=python \ - NOTIFY_API_KEY=${NOTIFY_API_KEY} \ - NOTIFY_API_URL=${NOTIFY_API_URL} - -COPY --from=root_dir Pipfile / -COPY --from=root_dir Pipfile.lock / -RUN pip install pipenv -RUN pipenv install --system - -COPY . /home/site/wwwroot -COPY ./database/schema.sql /home/site/wwwroot/database/schema.sql diff --git a/compose.yml b/compose.yml index 2cc7e123..77156aca 100644 --- a/compose.yml +++ b/compose.yml @@ -22,11 +22,11 @@ services: profiles: - dev - notify: - container_name: notify + notifications-api: + container_name: notifications-api network_mode: host build: - context: ./src/notify + context: ./src/notifications-api dockerfile: Dockerfile additional_contexts: root_dir: . diff --git a/infrastructure/tf-core/environments/development.tfvars b/infrastructure/tf-core/environments/development.tfvars index 46281b9d..eac1ed0c 100644 --- a/infrastructure/tf-core/environments/development.tfvars +++ b/infrastructure/tf-core/environments/development.tfvars @@ -147,8 +147,8 @@ function_app = { storage_uses_managed_identity = null worker_32bit = false - name_suffix = "communication-management" - function_endpoint_name = "CommunicationManagement" + name_suffix = "notifications-api" + function_endpoint_name = "NotificationsApi" app_service_plan_key = "Default" key_vault_url = "KEY_VAULT_URL" app_urls = [] diff --git a/infrastructure/tf-core/environments/integration.tfvars b/infrastructure/tf-core/environments/integration.tfvars index 5f00a16a..20460c07 100644 --- a/infrastructure/tf-core/environments/integration.tfvars +++ b/infrastructure/tf-core/environments/integration.tfvars @@ -147,8 +147,8 @@ function_app = { storage_uses_managed_identity = null worker_32bit = false - name_suffix = "communication-management" - function_endpoint_name = "CommunicationManagement" + name_suffix = "notifications-api" + function_endpoint_name = "NotificationsApi" app_service_plan_key = "Default" key_vault_url = "KEY_VAULT_URL" app_urls = [] diff --git a/infrastructure/tf-core/environments/nft.tfvars b/infrastructure/tf-core/environments/nft.tfvars index 66d86774..90f6d948 100644 --- a/infrastructure/tf-core/environments/nft.tfvars +++ b/infrastructure/tf-core/environments/nft.tfvars @@ -147,8 +147,8 @@ function_app = { storage_uses_managed_identity = null worker_32bit = false - name_suffix = "communication-management" - function_endpoint_name = "CommunicationManagement" + name_suffix = "notifications-api" + function_endpoint_name = "NotificationsApi" app_service_plan_key = "Default" key_vault_url = "KEY_VAULT_URL" app_urls = [] diff --git a/infrastructure/tf-core/environments/preprod.tfvars b/infrastructure/tf-core/environments/preprod.tfvars index 745a703f..da8c0de9 100644 --- a/infrastructure/tf-core/environments/preprod.tfvars +++ b/infrastructure/tf-core/environments/preprod.tfvars @@ -147,8 +147,8 @@ function_app = { storage_uses_managed_identity = null worker_32bit = false - name_suffix = "communication-management" - function_endpoint_name = "CommunicationManagement" + name_suffix = "notifications-api" + function_endpoint_name = "NotificationsApi" app_service_plan_key = "Default" key_vault_url = "KEY_VAULT_URL" app_urls = [] diff --git a/infrastructure/tf-core/environments/production.tfvars b/infrastructure/tf-core/environments/production.tfvars index 90ea9f25..a3204fed 100644 --- a/infrastructure/tf-core/environments/production.tfvars +++ b/infrastructure/tf-core/environments/production.tfvars @@ -147,8 +147,8 @@ function_app = { storage_uses_managed_identity = null worker_32bit = false - name_suffix = "communication-management" - function_endpoint_name = "CommunicationManagement" + name_suffix = "notifications-api" + function_endpoint_name = "NotificationsApi" app_service_plan_key = "Default" key_vault_url = "KEY_VAULT_URL" app_urls = [] diff --git a/infrastructure/tf-core/function_app.tf b/infrastructure/tf-core/function_app.tf index 21bc5f80..91ab7097 100644 --- a/infrastructure/tf-core/function_app.tf +++ b/infrastructure/tf-core/function_app.tf @@ -58,7 +58,9 @@ module "functionapp" { locals { - name_suffix = "communication_management" + name_suffix = "notifications-api" + function_endpoint_name = "NotificationsApi" + primary_region = [for k, v in var.regions : k if v.is_primary_region][0] app_settings = merge( var.function_app.env_vars_static, diff --git a/src/notify/Dockerfile b/src/notifications-api/Dockerfile similarity index 100% rename from src/notify/Dockerfile rename to src/notifications-api/Dockerfile diff --git a/app.py b/src/notifications-api/app.py similarity index 100% rename from app.py rename to src/notifications-api/app.py diff --git a/src/notify/app/__init__.py b/src/notifications-api/app/__init__.py similarity index 100% rename from src/notify/app/__init__.py rename to src/notifications-api/app/__init__.py diff --git a/src/notify/app/routes.py b/src/notifications-api/app/routes.py similarity index 100% rename from src/notify/app/routes.py rename to src/notifications-api/app/routes.py diff --git a/function_app.py b/src/notifications-api/function_app.py similarity index 100% rename from function_app.py rename to src/notifications-api/function_app.py diff --git a/host.json b/src/notifications-api/host.json similarity index 100% rename from host.json rename to src/notifications-api/host.json diff --git a/src/notify/local.settings.json b/src/notifications-api/local.settings.json similarity index 100% rename from src/notify/local.settings.json rename to src/notifications-api/local.settings.json diff --git a/src/notify/app.py b/src/notify/app.py deleted file mode 100644 index 7163aec4..00000000 --- a/src/notify/app.py +++ /dev/null @@ -1,7 +0,0 @@ -from app import create_app -import os - -app = create_app() - -if __name__ == "__main__": - app.run(debug=bool(os.environ.get("FLASK_DEBUG", False))) diff --git a/src/notify/function_app.py b/src/notify/function_app.py deleted file mode 100644 index d23cfaf0..00000000 --- a/src/notify/function_app.py +++ /dev/null @@ -1,14 +0,0 @@ -import azure.functions as func -from app import create_app - -funcapp = func.FunctionApp() -flaskapp = create_app() - - -@funcapp.route( - route="{*route}", - auth_level=func.AuthLevel.ANONYMOUS, - methods=[func.HttpMethod.GET, func.HttpMethod.POST], -) -def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse: - return func.WsgiMiddleware(flaskapp.wsgi_app).handle(req, context) diff --git a/src/notify/host.json b/src/notify/host.json deleted file mode 100644 index d7af4b62..00000000 --- a/src/notify/host.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "version": "2.0", - "extensionBundle": { - "id": "Microsoft.Azure.Functions.ExtensionBundle", - "version": "[4.*, 5.0.0)" - } -} - diff --git a/tests/integration/notify/__init__.py b/tests/integration/notify/__init__.py index edd4f37b..82a91a0d 100644 --- a/tests/integration/notify/__init__.py +++ b/tests/integration/notify/__init__.py @@ -2,4 +2,4 @@ import sys SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, os.path.dirname(SCRIPT_DIR) + "/../../src/notify/") +sys.path.insert(0, os.path.dirname(SCRIPT_DIR) + "/../../src/notifications-api/") diff --git a/tests/unit/notify/__init__.py b/tests/unit/notify/__init__.py index edd4f37b..82a91a0d 100644 --- a/tests/unit/notify/__init__.py +++ b/tests/unit/notify/__init__.py @@ -2,4 +2,4 @@ import sys SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, os.path.dirname(SCRIPT_DIR) + "/../../src/notify/") +sys.path.insert(0, os.path.dirname(SCRIPT_DIR) + "/../../src/notifications-api/")