An issue with Timer Trigger: The default code is not working as expected and I cannot see the correct log after deployment.

Ian Chen 0 Reputation points
2023-08-10T06:38:30.1066667+00:00

I am encountering an issue with Azure Functions. I have created a Timer Trigger function, and I have not made any modifications to the default code provided. However, after deploying the function, I am unable to see the expected correct log entries. I'm looking for assistance in resolving this issue and ensuring that the timer trigger function works correctly, generating the appropriate log output.

============================================User's image

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deepanshukatara-6769 16,565 Reputation points Moderator
    2023-08-10T07:16:13.6733333+00:00

    Function Configuration:

    • Check the function.json file in your function project. Ensure that the timer trigger is configured correctly with the desired schedule.
    • Confirm that the function name in function.json matches the actual function method name in your code
    0 comments No comments

  2. JananiRamesh-MSFT 29,261 Reputation points
    2023-08-10T13:32:40.08+00:00

    Hi Ian Chen Thanks for reaching out. I am unable to reproduce the issue at my end could you please confirm if this function runs locally?

    It worked fine for me locally on my VS code as well as in the portal.

    Seen the screenshots below:
    User's image

    Function Runtime Version**: 4.21.1.20667**

    Functions.json should be like below:

    {

    "scriptFile": "init.py",

    "bindings": [

    {
    
      "name": "mytimer",
    
      "type": "timerTrigger",
    
      "direction": "in",
    
      "schedule": "0 */5 * * * *"
    
    }
    

    ]

    }

    My host.json looks like below:

    {

    "version": "2.0",

    "logging": {

    "applicationInsights": {
    
      "samplingSettings": {
    
        "isEnabled": true,
    
        "excludedTypes": "Request"
    
      }
    
    }
    

    },

    "extensionBundle": {

    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    
    "version": "[3.*, 4.0.0)"
    

    }

    }

    init.py coder is below**:**

    import datetime

    import logging

    import azure.functions as func

    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)
    

    please verify if all the settings are same as above. Try changing the logs from filesystem logs to verbose and share me the details if the issue still persists.

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.