Azure function vs ASP.NET Core Worker Service?
Asked Answered
K

2

7

How does a Azure function differ from a ASP.NET Core Worker Service?

Does both of these cover the same use cases? How do I decide which one to use?

Koehn answered 12/12, 2019 at 12:36 Comment(1)
They're two distinct things. You can even have an ASP.NET Core worker service hosted as an Azure Function, effectively using both. No one can tell you what to do here. You're going to have to do your own research and make your own determination based on the needs of your app.Jemadar
P
8

Update:

Azure function is designed for azure. So when you use azure, or other azure services which are integrated with azure function, you should consider azure function, which could simplify your code and logic by the built-in features of azure function. But it will also have charges for azure function. And yes, if you don't use azure, just use asp.net core worker services.


Azure function are totally different from ASP.NET Core Worker Service.

The benefit of Azure function is that it supports a lot of triggers like azure blob trigger / azure event hub trigger, and is integrated with other azure services.

With these built-in features, it's easy to create a proper azure function to complete a proper task. For example, if you upload an image to azure blob storage, and then want to resize the image, you can easily create a blob trigger azure function with less code.

Worker services are the perfect use case for any background processing. And if you want to operation some azure services like azure blob / azure event hub etc. you may achieve this but need to do a lot of work.

At last, it depends on your use case to choose which one should be used, and select the simple / efficient one.

Planking answered 25/12, 2019 at 7:33 Comment(4)
I kind of know what an Azure function is, and I know about their triggers. Still it is not obvious how they compare against ASP.NET Core Worker Services, and which one is suitable for which scenarios. Is there any reason to even use ASP.NET Core Worker Services when Azure functions exists? Or is ASP.NET Core Worker Services only for people who don't use Azure?Koehn
@Fred, your consideration is correct. Azure function is designed for azure. So when you use azure, or other azure services which are integrated with azure function, you should consider azure function, which could simplify your code and logic by the built-in features of azure function. But it will also have charges for azure function. And yes, if you don't use azure, just use asp.net core worker services.Planking
If you edit your answer to integrate that information maybe it would be complete enough to accept it as an answer.Koehn
Okay, I accepted the answer. It was in poorly written English, but it was the only answer I got 20 days, so I feel I had to accept it.Koehn
T
3

I think the answer Fred was looking for is, why would someone use Azure functions over Asp.net Core hosted service? And the answer isn't only because you have Azure account so everything is easy and integrated. It depends. I.e Traffic, cost, expertise, etc. Actually, there are guidelines set by Microsoft when to use an Azure Functions versus let's say over a IHosted service running in a linux container hosted in AKS for example. and I'll post the link, but it's basically if your workload is mission critical or not. If you want the best performance, lowest cost, reliability a hosted dotnet core service running in Linux container would be an excellent alternative.

Here is the mission critical guidelines from Microsoft, hope this helps!

Design recommendations Azure Functions:

Consider Azure Functions for simple business process scenarios which don't have the same stringent business requirements as business-critical system flows.

Low-critical scenarios can also be hosted as separate containers within AKS to drive consistency, provided affinity and anti-affinity requirements are fully considered when collocating containers on nodes.

Excerpt taken from here:

https://learn.microsoft.com/en-us/azure/architecture/framework/mission-critical/mission-critical-application-platform

Torin answered 24/10, 2022 at 11:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.