2

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.

191180rk
  • 735
  • 2
  • 12
  • 37

2 Answers2

2

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://learn.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.

Cindy Pau
  • 13,085
  • 1
  • 15
  • 27
  • My requirement is, message drops in the Azure queue which triggers console application which does 'n' number of activities which may last for 30 minutes. Can I port this long running application code to Azure Durable function without refactoring so that durable function will withstand 30 mins execution period? With code refactoring I know we can have different activities to different Azure activity function & get it done via durable function though entire process takes around 30 minutes. But I want to do it without code refactoring, any options in durable function to support such use case? – 191180rk Feb 06 '20 at 04:45
1

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

  • Hearing "Azure container instance" for first time. Can you add bit more details to it & reference document link please. How much effort consuming is, creating a docker image of the console application? Where the image will be stored? to create instance out of it on every queue trigger message arrival. – 191180rk Jun 29 '20 at 15:13
  • Yes Sure, Azure container instance is the way to run containers on the azure cloud in serverless fashion. So what you need to do is add a dockerfile for your console application. create a docker image for your project and upload it to azure container registry. Your console application should poll a message from queue and when no messages are left it should exit from main function so that your container stops and so does the billing. After this is all done you will just write a simple azure function to watch your queue and start the container when message arrives. – huzefa qubbawala Jun 30 '20 at 04:32
  • thanks @huzefa, it helps. Will come back if I need more help – 191180rk Jun 30 '20 at 07:41
  • 1
    Glad to help, please upvote if you think this was useful – huzefa qubbawala Jul 02 '20 at 06:30