1
votes

I have a long running activity whose execution completion time will be more than 10 mins but it is single activity with many internal tasks. I want to run this long running activity as Azure Function on consumption plan but not on premium (or) on app service for cost factors. But Azure function on consumption plan has max. timeout period of 10 mins so Azure function on consumption plan won't fit.

For the above requirement, is Azure Durable function right choice? where I can spin up durable function on consumption plan and thought of calling long running function as an activity in Durable function "orchestrationcontext" (though my requirement is nothing to do with orchestration or functional chaining) to overcome Azure function timeout limitation in cost efficient way.

Is above approach technically possible? Won't the activity function within Durable function "orchestrationcontext/DurableClient", get time outed after 10 mins on consumption plan? Is it with in best practices? please clarify.

2

2 Answers

0
votes

Functions are supposed to be short-lived, they shouldn't run long time.The strength of Functions is in short-lived executions with small- or variable throughput.

Whenever possible, refactor large functions into smaller function sets that work together and return responses fast. For example, a webhook or HTTP trigger function might require an acknowledgment response within a certain time limit; it's common for webhooks to require an immediate response. You can pass the HTTP trigger payload into a queue to be processed by a queue trigger function. This approach lets you defer the actual work and return an immediate response.

Have a look of this:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-best-practices#avoid-long-running-functions

With Durable Functions you can easily support long-running processes, applying the Async HTTP APIs. When in case you are dealing with functions that require some time to process the payload or request, running under an 'App Service Plan, WebJob, or Durable Functions' is the right way.

0
votes

If i understand your requirement your primary objective of using durable function is to go serverless and pay only for what you used.

If the above understanding is correct then you cannot solve your problem without breaking your 30min long running function to multiple activity functions which can be completed in 5mins or max 10mins.

But you can use different approach to solve your problem statement.

You can create a docker image of your console application, deploy it to azure container registry and once the message arrives in queue you can write a simple queue trigger azure function which can start this image using Azure container instance.

Azure container instance is serverless and only charges you for execution time which is 30mins in your case.

This will solve your problem of not refactoring the code and still using serverless model.

Let me know your thoughts for the same