Home > front end >  C# console application in Azure
C# console application in Azure

Time:01-31

I have a console application in C# that search for specific records in DB and outputs them to the console. For the console application to find and list all the records it usually takes 30 minutes. If I want to automate that console application to run at specific time and save the records to csv file what feature from Azure platform I can use? Is Azure function suitable for this task or there are some other Azure features I can use?

I tried to investigate Azure Function, however it looks the functions are not suitable for long running task that takes longer than 5 minutes.

CodePudding user response:

A Premium function can run for longer than 5 minutes (a consumption function maxes out at 10 minutes btw).

This is a fudge but you could also take the console app wrap it in a container, run that container in an Azure container instance and start it with a logic app. You only pay for the runtime of the container.

I'd probably ask why it takes 30 minutes to find all the records, is there a better way of running the query?

CodePudding user response:

You could use Azure Durable Functions, but your algorithm should implement Continuation Token logic. Means, that you have some token (which could be JSON object with some properties), and that token allows you to start/continue your algorithms from any point of time.

For example - you are searching for specific records in DB, and memorize current processed DB primary key of the row. And you store it in your continuation token, and that token is stored in Azure Storage Container Blob, or in Table. When your function will be stopped (b/t it will run more than 10 minutes), and will be started again - you will check value of that token, and start search from that point.

  • Related