Azure Function error when defining a timer

Guillaume THIERY 0 Points de réputation
2025-05-25T06:15:26.1066667+00:00

Hello,

I have deployed a Powershell Function App on Azure. The script works and can be trigerred with :

*/59 * * * * *

From 0 to 59 seconds, it works but I want to run this script every 5 minutes.

When I configure the minutes, the function does not work anymore and I get this error :

2025-05-22T15:04:32Z [Error] Executed 'Functions.ps-test' (Failed, Id=989e2385-f915-4f15-bda3-527c03ec353e, Duration=2ms)

I tried different configurations and it always results in the same error.

  • */5 * * * * 0 */5 * * * *

My format seems good but the function fails. What is wrong ? I need to run this script every 5 or 10 minutes, how can I do it ?

Windows pour les entreprises | Windows Server | Expérience utilisateur | PowerShell

2 réponses

Trier par : Le plus utile
  1. Guillaume THIERY 0 Points de réputation
    2025-06-03T07:39:29.1833333+00:00

    The issue is not inside my script ! My script works. I tried with a simple test script, I kept the default script generated by Azure and added one Write-Host :

    # Input bindings are passed in via param block.
    param($Timer)
    
    # Get the current universal time in the default string format.
    $currentUTCtime = (Get-Date).ToUniversalTime()
    
    # The 'IsPastDue' property is 'true' when the current function invocation is later than scheduled.
    if ($Timer.IsPastDue) {
        Write-Host "PowerShell timer is running late!"
    }
    
    # Write an information log with the current time.
    Write-Host "PowerShell timer trigger function ran! TIME: $currentUTCtime"
    
    Write-Host "Function works"
    
    

    I kept the default trigger generated by Azure (function.json)

    {
      "bindings": [
        {
          "name": "Timer",
          "type": "timerTrigger",
          "direction": "in",
          "schedule": "0 */5 * * * *"
        }
      ]
    }
    
    

    And it does not work ! I get this log :

    2025-06-03T07:20:26Z [Information] Executing 'Functions.TimerTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=04ec27a3-8ab9-4e65-bd33-d55f12f9250d)

    2025-06-03T07:20:26Z [Error] Executed 'Functions.TimerTrigger1' (Failed, Id=04ec27a3-8ab9-4e65-bd33-d55f12f9250d, Duration=12ms)

    By editing the schedule ONLY and defining " */59 * * * * * ", it works !

    2025-06-03T07:37:03Z [Information] Executing 'Functions.TimerTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=80095f9d-a513-45cc-bb2c-105b9e3eb9ce)

    2025-06-03T07:37:03Z [Verbose] Sending invocation id: '80095f9d-a513-45cc-bb2c-105b9e3eb9ce

    2025-06-03T07:37:03Z [Verbose] Posting invocation id:80095f9d-a513-45cc-bb2c-105b9e3eb9ce on workerId:35896789-7614-4118-bf66-197868c1a7df

    2025-06-03T07:37:03Z [Information] INFORMATION: PowerShell timer trigger function ran! TIME: 06/03/2025 07:37:03

    2025-06-03T07:37:03Z [Information] INFORMATION: Function works

    2025-06-03T07:37:03Z [Information] Executed 'Functions.TimerTrigger1' (Succeeded, Id=80095f9d-a513-45cc-bb2c-105b9e3eb9ce, Duration=32ms)

    The issue is not in the script ... I don't understand why this behavior ...

    Could it be related to my App Service Plan ? I'm using "Y1", and a "Consumption" hosting plan.

    Cette réponse vous a-t-elle été utile?

    0 commentaires Aucun commentaire

  2. Smith Pham 2,795 Points de réputation Conseiller(ère) indépendant(e)
    2025-05-30T09:47:25.88+00:00

    Dear Guillaume

    To run your Azure PowerShell Function every 5 minutes, use this CRON expression:

    
    Copy
    0 */5 * * * *
    

    Don't use */5 * * * * — it's incorrect in Azure.

    You're using the wrong format. Azure requires 6 fields, starting with seconds.

    Cette réponse vous a-t-elle été utile?


Votre réponse

Les réponses peuvent être marquées comme « Acceptées » par l’auteur(e) de la question et « Recommandées » par les modérateurs, ce qui aide les utilisateurs à savoir que la réponse a résolu le problème de l’auteur(e).