Azure Function App Only Runs When In Azure Portal

Michael C 21 Reputation points
2021-02-14T15:11:06.167+00:00

Hi,

I have recently Published an Azure Function from Visual Studio. The function is setup to trigger every 15 minutes. This works fine when I am logged in to the Portal but when I'm not logged in the function does not trigger.

Things I have tried:

Like I say the Function App works exactly as I expect it to when I am logged in so I've obviously done something wrong when publishing/setting up the Function.

Any help would be appreciated!

I'm not sure if the page https://github.com/Azure/azure-functions-host/wiki/Investigating-and-reporting-issues-with-timer-triggered-functions-not-firing is still relevant but I have included the requested information regardless:

  1. Are you using Consumption or App Service Plan - Consumption
  2. If Consumption, how did you deploy? If App Service Plan, do you have Always On enabled? - I deploy the function using 'Publish' in Visual Studio 2019
  3. Are you using the v1 runtime, or the v2 (Preview) runtime? - v3.0
  4. Are you setting WEBSITE_TIME_ZONE? - No
  5. What is your CRON expression set to, and what is your expectation about what it means. - I expect the function to fire every 15 minutes. My CRON syntax is included below.
  6. Give a specific UTC time at which you expected your function to get called, and found that it wasn't. Also, explain how you are determining that it is not getting called. If some cases, the function may get called, but it may not be obvious due to some logging issue - The overview in the Azure Portal shows that it hasn't been run. Also the Function would make an entry in to a database table each time it runs
  7. And most importantly, include a sample invocation ID so we can find your app and look into the issue - Region is UK South invocation ID is below:

Executing 'UpdateMeterReadings' (Reason='Timer fired at 2021-02-14T15:00:00.0099970+00:00', Id=b77b5b73-37cf-4c80-8469-5395b52b7088)

Function Code and CRON syntax:

[FunctionName("UpdateMeterReadings")]  
public void Run([TimerTrigger("*/15 * * * *")]TimerInfo myTimer)  
{  
     _log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");  
  
     RecordMeterReadings(UtilityType.Electric);  
     RecordMeterReadings(UtilityType.Gas);  
}  
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,978 questions
0 comments No comments
{count} votes

Accepted answer
  1. Nasreen Akter 10,791 Reputation points
    2021-02-14T15:29:01.453+00:00

    Hi @MichaelCruse-4449,

    I think you are only missing a 0 at the beginning of your CRON expression.

     It should be 0 */15 * * * * instead of */15 * * * *. 
    

    Thanks!


    If the above response is helpful, please Accept as Answer and Upvote it. Thanks!


2 additional answers

Sort by: Most helpful
  1. Shubham Tomar 1 Reputation point
    2022-10-12T07:02:20.017+00:00

    Hi @Michael C @Nasreen Akter
    I am facing same problem but in my case I have not set any time to trigger blob storage. Instead I just want, when I upload a file to azure blob storage, the function app triggers the blob immediately. It works fine when I log in to Function App Portal, but when I log off or close the log stream in Function App Portal the Function App doesn't trigger the blob.

    Kidly, please help me to resolve this issue.
    Thanks

    Plese answer here or there https://learn.microsoft.com/en-us/answers/questions/1044634/function-app-blob-trigger-only-works-when-i-open-l.html

    0 comments No comments

  2. Shubham Tomar 1 Reputation point
    2022-10-12T09:15:19.693+00:00

    Now I got it:-

    Polling and latency
    Polling works as a hybrid between inspecting logs and running periodic container scans. Blobs are scanned in groups of 10,000 at a time with a continuation token used between intervals. If your function app is on the Consumption plan, there can be up to a 10-minute delay in processing new blobs if a function app has gone idle.

    Solutions:-
    If you require faster or more reliable blob processing, you should instead implement one of the following strategies:

    • Change your binding definition to consume blob events instead of polling the container. You can do this in one of two ways:
      • Add the source parameter with a value of EventGrid to your binding definition and create an event subscription on the same container. For more information, see Tutorial: Trigger Azure Functions on blob containers using an event subscription.
      • Replace the Blob Storage trigger with an Event Grid trigger using an event subscription on the same container. For more information, see the Image resize with Event Grid tutorial.
    • Consider creating a queue message when you create the blob. Then use a queue trigger instead of a blob trigger to process the blob.
    • Switch your hosting to use an App Service plan with Always On enabled, which may result in increased costs.

    It's mentioned in the documentation itself https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger?tabs=in-process%2Cextensionv5&pivots=programming-language-python

    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.