Azure Functions Development Best Practices : Bindings vs EF Core

Marco S. Junior 46 Reputation points
2022-12-05T16:22:48+00:00

I know the big thing about Azure Functions is to use the Bindings...and I love it :-)

For MSSQL, you put the query, the connection and voilá...Work like a charm...

But what about use EF Core ? If I do it, I can't use Bindings, right ?
Is EF Core an anti-pattern for Azure Functions ? Maybe I am wrong and it's possible to use bindings with EF Core?

What is your opinion ?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,929 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MikeUrnun 9,777 Reputation points Moderator
    2022-12-05T21:02:00.83+00:00

    Hello @MarcoSJunior-5055 - Thanks for reaching out! Below are my inputs on the questions you raised:

    But what about using EF Core? Maybe I am wrong and it's possible to use bindings with EF Core?

    It's definitely possible to use EF Core in your Azure Functions, and the best way is via a Dependency Injection, as demonstrated here: Entity Framework on Azure Functions with Dependency Injection

    Is EF Core an anti-pattern for Azure Functions? If I do it, I can't use Bindings, right?

    I think being able to leverage DI for well-organized abstractions of EF Core & Functions integration is something very positive for our consideration. Now, how useful and efficient that is to the overall workload & development effort is the next to consider. If your functions interact with SQL data at a minimum and don't carry out complex data-handling operations, using Bindings and structuring your functions accordingly is sufficient.

    Conversely, if your workload does require a lot of data handling where the use of ORM can be more effective, there's nothing wrong with start using EF Core. Although I would also be mindful of stateful and stateless workloads, and consider using Durable Functions when it makes more sense.

    I hope my answers are helpful, feel free to let me know if you have any further questions.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.