From a397f9a3f9e17d01f5af800b8d3eb1575938acf7 Mon Sep 17 00:00:00 2001 From: Mitchell Laferla Date: Tue, 5 Sep 2023 08:59:59 -0700 Subject: [PATCH] reconfig host --- function_app.py | 64 ------------------------------------------------- host.json | 20 +++++++++------- 2 files changed, 11 insertions(+), 73 deletions(-) delete mode 100644 function_app.py diff --git a/function_app.py b/function_app.py deleted file mode 100644 index 1a59399..0000000 --- a/function_app.py +++ /dev/null @@ -1,64 +0,0 @@ -import azure.functions as func -import os -import datetime -import logging -import sys -import importlib.util - -# Azure function timer. To alter timer cadence see function.json file -app = func.FunctionApp() - -@app.function_name(name="monitoring_weekly") -@app.schedule(schedule="0 5 * * MON", - arg_name="mytimer", - run_on_startup=False, - use_monitor=True) - -def main(mytimer: func.TimerRequest) -> None: - utc_timestamp = datetime.datetime.utcnow().replace( - tzinfo=datetime.timezone.utc).isoformat() - - if mytimer.past_due: - logging.info('The timer is past due!') - - logging.info('Python timer trigger function ran at %s', utc_timestamp) - - -def run_script(script_name): - script_path = os.path.join(os.path.dirname(__file__), f'{script_name}') - - s = importlib.util.spec_from_file_location(script_name, script_path) - m = importlib.util.module_from_spec(s) - sys.modules[s.name] = m - s.loader.exec_module(m) - - -def batch_execution(file_list): - - exceptions = [] #store errors - - for file in file_list: - try: - run_script(file) - except Exception as e: - exceptions.append(e) - else: - print('Success') - - return exceptions - -#list of scripts running in function, if adding new script add to list. -file_list = ['weekly_sama_reporting.py', - 'weekly_autolinker_100_links_audit.py', - 'weekly_insights_brand_monitoring.py', - 'weekly_new_brand_combos.py', - 'weekly_new_store_monitoring.py'] - -batch_execution(file_list) - - -# run_script('weekly_sama_reporting.py') -# run_script('weekly_autolinker_100_links_audit.py') -# run_script('weekly_insights_brand_monitoring.py') -# run_script('weekly_new_brand_combos.py') -# run_script('weekly_new_store_monitoring.py') diff --git a/host.json b/host.json index eb8a4b4..a10ece6 100644 --- a/host.json +++ b/host.json @@ -1,14 +1,16 @@ { - "version": "2.0", - "extensionBundle": { - "id": "Microsoft.Azure.Functions.ExtensionBundle", - "version": "[4.0.0, 5.0.0)" - }, - "extensions": { - "timer": { - "maxConcurrentExecutions": 1, - "scheduleStatusFilePath": "app_offline.htm" + "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