0
votes

I have a function app with:

  • a few functions triggered by a Timer Trigger
  • and some triggered by the HTTP Trigger.

I have also an Azure API Management service set up for the function app, where the HTTP Triggered functions have their endpoints defined.

I am trying to trigger one of my timer triggered functions manually as per the guide here https://docs.microsoft.com/en-us/azure/azure-functions/functions-manually-run-non-http

I am however getting a 404 result in Postman, despite the seemingly correct URL and x-functions-key.

The function: enter image description here

The key:

enter image description here

The request:

enter image description here

I also noticed that:

  • if I don't include the x-functions-key header, then I get 401 Unauthorized result
  • and if I include an incorrect key, then I get 403 Forbidden.

Could it be related to the API management service being set up for the function app?

How can I troubleshoot this further?

2

2 Answers

1
votes

I test it in my side, it works fine. Please refer to the below screenshot:

enter image description here

Please check if you request https://xxx.azurewebsites.net/admin/functions/TimerTrigger1 but not https://xxx.azurewebsites.net/admin/functions/TimerTrigger. Note it's "TimerTrigger1".

I requst with ..../TimerTrigger at first test because the document shows us QueueTrigger, and it response 404.

1
votes

I have managed to solve it.

It turns out that Azure Functions timer trigger requires six parts cron expression (I was only aware of the five part style)

Without that, it does not work - sadly this is not easily noticeable in the UI. I have realized that by investigating Application Insights logs:

enter image description here

The function page shows that everything is fine:

enter image description here

Changing the CRON format has fixed the 404 issue and I started getting 202 Accepted response.

As a bonus note, I have to add:

Even though the response was 202 Accepted, the triggering didn't work correctly, because my function return type was Task<IActionResult> which is not accepted for timer triggered functions.

Again, only ApplicationInsights showed that anything is wrong:

The 'MonkeyUserRandom' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'MonkeyUserRandom'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter '$return' to type IActionResult&. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

That's a bonus tip for a 'manual triggering of non-http function does not work'.