Search code examples
.netazureazure-functionstimer-trigger

Keeping user session alive with Azure Function


Since I cannot trigger a Timer-based function with a queue or providing it with a param (session id to keep it alive, refreshing it every 30 minutes), is it possible to create a basic HTTP/Queue Function (and NOT Timer function) and add a c# code inside with a custom timer? Will the function once triggered run forever?


Solution

  • No as @Will mentioned in his comment, you cannot use Azure Function to run forever (continuously). As the design of Azure Functions is intended to work for less load with-in specific time limit.

    The time limit of Consumption Plan says

    The default timeout for functions on a Consumption plan is 5 minutes. The value can be increased for the Function App up to a maximum of 10 minutes by changing the property function timeout in the host.json project file.

    So as a best practice you should avoid long running jobs in Azure Function.

    For your use case, you can use Azure Web Apps. Azure Web Apps are the one which is designed for long running jobs.

    1. You can create a basic HTTP/Queue Function
    2. Which in turn cal your
    3. Azure Web Apps Azure web apps then run forever as you wish.