There are too many functions in your function app, they may interact each other. I met similar problem with this, in that case, the timer trigger functions in one function app and did not work. But when i deploy them to different function apps, they work fine. so you can try to deploy your second function to another function app.
And I suggest you report this problem to Microsoft, they can know more information about this problem, and may have a better solution.
AFAIK, There is no specific reason for the timer trigger not firing properly within the given time.
Few of the workaround we can follow,
I have not faced the similar issue yet, would suggest you to please try to restart/refresh your function app. or, It may be due to of the sync issue with the function which is not happening properly.
As suggested by @Anand Sowmithiran the SO THREAD, @MayankBargali-MSFT suggest about singleton lock i,e;
TimerTrigger uses the Singleton feature of the WebJobs SDK to ensurethat only a single instance of your triggered function is running atany given time. When the JobHost starts up, for each of yourTimerTrigger functions a blob lease (the Singleton Lock) is taken. This distributed lock ensures that only a single instance of yourscheduled function is running at any time. If the blob for thatfunction is not currently leased, the function will acquire the leaseand start running on schedule immediately. If the blob lease cannot beacquired, it generally means that another instance of that function isrunning, so the function is not started in the current host.
Also please try to set to false to check whether its behaving the same or not as provided the MS DOC in comment.runonstartup
For more information Please refer the below links :-
MS Q&A| Azure Timer Trigger not firing
GitHub | azure timer function not executing all of sudden
Thanks to JaliyaUdagedara for answering to this thread - Azure Function (REST API for Http Trigger & using Timer Trigger with Azure Data Factory) - Microsoft Q&A
So, if I use Timer Trigger and have a logic to pull list of data, how do I move the data to ADF?
As far as I know, ADF cannot directly use .Timer trigger function
But you can create schedule triggers in Azure Data Factory first:
Then create a new , and write the logic originally written in Http Trigger Function in Time Trigger Function. Then use the Http trigger function in ADF.Time Trigger Function
For how to use azure function in ADF, you can refer to this blog.
The logs of azure function is fragile. So sometimes you can not see the logs, but this doesn't mean the azure function is not run.
If you want to know the function is running you need to go to the kudu of your azure function and see the logs file of your function app.(The logs in Application Insights is coming from this place.)
The logs file is in the place:
Open your brower and go to , and then click into LogFiles/Application/Functions/Function/yourtriggername . You will find the log file in this place.https://yourfunctionappname.scm.azurewebsites.net/DebugConsole
I have reproduced in my environment by taking both the HTTP and Timer Trigger Functions in the same Function Class file - Python Version 3.9.13
Local Execution:
Configuration:
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing" to the Function App Configuration.Azure Cloud Portal - Function App Execution:
func azure functionapp publish <your_FunctionApp_Name_inTheAzurePortal>
Note: You can add them either before or after publishing to the Azure Portal.
And I can see both the Functions:
Http Trigger Function Run:
Timer Trigger Function Run:
Code Snippets:
function_app.py:
import azure.functions as func
import logging
import datetime
import os
from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential
app = func.FunctionApp()
@app.function_name(name="HttpTrigger1") #Http_Trigger
@app.route(route="hello")
def test_function(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
keyVaultName = os.environ["KEY_VAULT_NAME"]
logging.info(f'TestEnvFromKeyVault: {keyVaultName}')
logging.info('Python Http trigger function ran at %s', utc_timestamp)
return func.HttpResponse("Hello Krishna, This HTTP triggered function executed successfully.",
status_code=200
)
# Timer_Trigger_in_same_function
@app.function_name(name="mytimer")
@app.schedule(schedule="0 */1 * * * *", arg_name="mytimer", run_on_startup=True,
use_monitor=False)
def test_function(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)
host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.15.0, 4.0.0)"
}
}
requirements.txt file:
azure-functions
azure.keyvault.secrets
azure.identity
azure-keyvault
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=krishfunappstorage;AccountKey=<Storage-Account-Access_Key>;EndpointSuffix=core.windows.net",
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
"KEY_VAULT_NAME":"krishkv4funapp"
}
}
Above parts of code sample taken from the below references: