Search code examples
c#.netazure-functionsazure-durable-functionstimer-trigger

TimerTrigger is not firing the function


I have an Azure Durable Function (v3) that I scheduled to run on Saturdays at 20:30 (8:30PM). On Sunday Morning I saw that it did not run so I scheduled it to run on Mondays at 20:30. I do that by deploying new zip package with the new TimerTrigger set up. The app ran on Monday, but it did not perform all the work I wanted it to do. On Wednesday around 13:00, I added some logging and scheduled the app to run everyday at 20:30:

public async Task Start([TimerTrigger("0 30 20 * * *")] TimerInfo timerInfo,
            [DurableClient] IDurableOrchestrationClient starter,
            ILogger log)
        {
// ...
        }

I checked today (Thrusday morning) and the function did not fire. I opened logs on Azure Storage and I see only the run from Monday:

2021-04-19T20:30:00.058 [Information] Executing 'KreptdIntegration_Start' (Reason='Timer fired at 2021-04-19T20:30:00.0215809+00:00', Id=8c40e15b-a740-4956-a6e6-b90b8fe95f3a)
2021-04-19T20:30:00.338 [Information] Started orchestration with ID = 'kreptdintegrationsingleinstance'.
2021-04-19T20:30:00.364 [Information] Executed 'KreptdIntegration_Start' (Succeeded, Id=8c40e15b-a740-4956-a6e6-b90b8fe95f3a, Duration=331ms)

In the monitor section of the function in Azure portal I also see only information about the run from Monday: enter image description here

Why is the function not triggering? Is it possible that I scheduled the function too late? (I scheduled it around 13:00 to run at 20:30 the same day. Is it possible to trigger the function manually from Azure portal if it's a function written in C# and deployed as a package?


Solution

  • To make sure that the new trigger works, it needs to by synced. You can sync triggers in one of three ways:

    • Restart your function app in the Azure portal
    • Send an HTTP POST request to https://{functionappname}.azurewebsites.net/admin/host/synctriggers?code=<API_KEY> using the master key.
    • Send an HTTP POST request to https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME>/providers/Microsoft.Web/sites/<FUNCTION_APP_NAME>/syncfunctiontriggers?api-version=2016-08-01.

    Replace the placeholders with your subscription ID, resource group name, and the name of your function app.

    Source: https://learn.microsoft.com/en-us/azure/azure-functions/functions-deployment-technologies#trigger-syncing