Caverman
Caverman

Reputation: 3759

Azure Functions how much code can be done in one?

I am a complete newbie for Azure and Azure Functions but my team plans to move to Azure soon. Now I'm researching how I could use Azure Functions to basically do what I would normally do in a .Net console application.

My question is, can Azure Functions handle quite a bit of code processing?

Our team uses several console apps that effectively pick up a pipe delimited file, do some business logic, update a database with the data, and log everything along the way. From what I've been reading so far I typically see that Azure Functions are used for little pieces of code. How little do they mean? Is it best practice to have a bunch of Azure Functions to replace a console app EX: have one function that does the reading of a file and create a list of objects, another function to loop through those items and add business logic, and then another to write the data to a database or can I use one Azure Function to do all of that?

Upvotes: 1

Views: 1539

Answers (3)

Michał Jarzyna
Michał Jarzyna

Reputation: 1916

Direct answer is yes - you can run bigger pieces of code as Azure Function - this is not a problem as long as you meet their limitations. You can even have dependency injecton. For chained scenarios, you can use Durable Functions. However, Microsoft do not recommend long running functions, cause of unexpected timeouts. See best practices for azure functions.

Because of that, I would consider alternatives:

Upvotes: 4

Cristian Sarghe
Cristian Sarghe

Reputation: 790

You can do all of that in one function.

If you need on-the-fly data processing, you can safely use Azure Functions even if it takes reading files or database communication.

What you need to be careful at and configure, though, is the timeout. Their scalability is an interesting topic as well.

If you need to host an application, you need a machine or a part of the storage space of a machine in Azure to do that.

Upvotes: 0

Thiago Custodio
Thiago Custodio

Reputation: 18362

This is really hard to answer because we don't know what kind of console app you have over there. I usually try to use the same SOLID principles used to any class on my functions too. And whenever you need to coordenate actions or if you need to run things in parallel you always use Durable Functions Framework too.

The only concern is related to execution time. Your function cans get pretty expensive if you're running on consumption plan and do know pay attention to it. I recommend you the reading of the following gread article:

https://dev.to/azure/is-serverless-really-as-cheap-as-everyone-claims-4i9n

Upvotes: 0

Related Questions