I'm writing my first, timer-triggered Functions and I'm having problems configuring them to run on their own. For explanation let's focus on just one.
The functions logs as run successfully but thanks to logging I identified that every time function is run "myTimer.past_due" returns "false" and function logic does not start.
How should I set it up so it would return "true" reliably?
How should i set it up so it would runvia "test-code" form portal?
What do i not get here? Is there some other timer that has to be matched?
I even went through and "turned it off and on again" by settig up new functions app and storage account in Azure to be sure i haven't broken up some settings on my way to this point.
Rationale: This one is ETL function that connects to third-party platform via API and inserts required data into azure SQL database. I would like it to run at 1 am each day. For starting function script I used the one provided via Microsoft DOC page, slightly modified, from here: https://docs.microsoft.com/pl-pl/azure/azure-functions/functions-bindings-timer?tabs=python
Here is mine "init.py":
import datetime
import logging
import azure.functions as func
from Toggl_Data_Procurement_Function import toggl_script
def main(myTimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
logging.info(f"myTimer.past_due: {myTimer.past_due}")
if myTimer.past_due:
logging.info('Function %s, started by timer trigger, started running at %s', func.Context.function_name, utc_timestamp)
toggl_script.TogglDataProcurementScript(root_directory=str(func.Context.function_directory)).run()
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
logging.info('Function %s, started by timer trigger finished running at %s', func.Context.function_name, utc_timestamp)
Here is my function.json - for debbugging I've set it up to run every 15 mins:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */15 * * * *",
"useMonitor": true
}
]
}
Here is my local.settings.json. I edited out the storage account & instrumentation keys but they are the ones copied from appropriate app keys from platform:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_EXTENSION_VERSION": "~3",
"FUNCTIONS_WORKER_RUNTIME": "python",
"APPINSIGHTS_INSTRUMENTATIONKEY": "secret_key_2",
"APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=secret_key_2;IngestionEndpoint=https://centralus-0.in.applicationinsights.azure.com/",
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=account_name;AccountKey=secret_key;EndpointSuffix=core.windows.net",
}
}

