From a0e890b1a0127f7eecafd420d28a0938d82ffe15 Mon Sep 17 00:00:00 2001 From: Trevor Blanarik Date: Wed, 31 May 2023 22:29:42 +0000 Subject: [PATCH 1/3] clean up messy duplicated functions with single cron expression --- function_app.py | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/function_app.py b/function_app.py index 39d81f0..6633231 100644 --- a/function_app.py +++ b/function_app.py @@ -16,38 +16,11 @@ def manual_run(req: func.HttpRequest) -> func.HttpResponse: traffic_report(2532, debug=True) return func.HttpResponse("Finished checking traffic") -@app.function_name(name="timertrigger730") -@app.schedule(schedule="30 14 * * 1-5", - arg_name="timertrigger730", +@app.function_name(name="timertrigger") +@app.schedule(schedule="30,45 14,23 * * 1-5", + arg_name="timertrigger", run_on_startup=False) -def timer_trigger_730(timertrigger730: func.TimerRequest) -> None: - traffic_report(2530) - traffic_report(2532) - - -@app.function_name(name="timertrigger745") -@app.schedule(schedule="45 14 * * 1-5", - arg_name="timertrigger745", - run_on_startup=False) -def timer_trigger_745(timertrigger745: func.TimerRequest) -> None: - traffic_report(2530) - traffic_report(2532) - - -@app.function_name(name="timertrigger430") -@app.schedule(schedule="30 23 * * 1-5", - arg_name="timertrigger430", - run_on_startup=False) -def timer_trigger_430(timertrigger430: func.TimerRequest) -> None: - traffic_report(2530) - traffic_report(2532) - - -@app.function_name(name="timertrigger445") -@app.schedule(schedule="45 23 * * 1-5", - arg_name="timertrigger445", - run_on_startup=False) -def timer_trigger_445(timertrigger445: func.TimerRequest) -> None: +def timer_trigger(timertrigger: func.TimerRequest) -> None: traffic_report(2530) traffic_report(2532) From 3080d126fda2218809202e2b8bd32f85e4e37848 Mon Sep 17 00:00:00 2001 From: Trevor Blanarik Date: Wed, 31 May 2023 22:35:01 +0000 Subject: [PATCH 2/3] adds more useful commands --- commands.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/commands.md b/commands.md index 3814038..46865e0 100644 --- a/commands.md +++ b/commands.md @@ -1,7 +1,13 @@ +# Azure Function Core Tools + +```bash +npm i -g azure-functions-core-tools@4 --unsafe-perm true +``` + # Deploy ```bash -func azure functionapp publish daily-traffic-function +func azure functionapp publish daily-traffic-function --python ``` # Init function From b8af8441ff808c894588ecb45fbefd252406c355 Mon Sep 17 00:00:00 2001 From: Trevor Blanarik Date: Thu, 1 Jun 2023 00:06:34 +0000 Subject: [PATCH 3/3] Azure Functions use NCronTab, so I need seconds in here --- function_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/function_app.py b/function_app.py index 6633231..cbb8f10 100644 --- a/function_app.py +++ b/function_app.py @@ -17,7 +17,7 @@ def manual_run(req: func.HttpRequest) -> func.HttpResponse: return func.HttpResponse("Finished checking traffic") @app.function_name(name="timertrigger") -@app.schedule(schedule="30,45 14,23 * * 1-5", +@app.schedule(schedule="0 30,45 14,23 * * 1-5", arg_name="timertrigger", run_on_startup=False) def timer_trigger(timertrigger: func.TimerRequest) -> None: