diff --git a/cleanup.py b/cleanup.py new file mode 100644 index 0000000..e4f77a1 --- /dev/null +++ b/cleanup.py @@ -0,0 +1,4 @@ +import logging + +def cleanup(): + logging.info("Executing table cleanup function") \ No newline at end of file diff --git a/function_app.py b/function_app.py index 28e390a..ed76abf 100644 --- a/function_app.py +++ b/function_app.py @@ -1,5 +1,6 @@ import azure.functions as func import spotbot as sb +import cleanup import logging app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION) @@ -12,4 +13,15 @@ def spotbot(req: func.HttpRequest) -> func.HttpResponse: logging.error(f"Exception occurred: {_excpt}") return func.HttpResponse(body=f"Exception occurred: {_excpt}", status_code=500) else: - return func.HttpResponse(status_code=202) \ No newline at end of file + return func.HttpResponse(status_code=202) + +@app.function_name(name="tablecleanup") +@app.schedule(schedule="0 8 * * *", + arg_name="tablecleanup", + run_on_startup=False) +def table_cleanup(timer: func.TimerRequest) -> None: + cleanup.cleanup() + +@app.route(route="manualcleanup", methods=[func.HttpMethod.POST]) +def manual_cleanup(req: func.HttpRequest) -> func.HttpResponse: + cleanup.cleanup() \ No newline at end of file