[SOLVED] Azure Function App & Web API in same solution


I need a both a Web API project and a function app project which share the same services / class libraries etc. A few questions

  1. Is it bad practice to place them both in the same solution (or should they be in seperate repositories
  2. Should the services be registered in the Startup class of the Web Api or the function app, or a mixture of the 2? Is it okay to register services only used by the function app in the web api startup class as this would make life easier? The services will do similar things and in some cases the same services will be used by both.

I am likely to only require a few timer trigger functions, most of the application will be build on the web api.

Specifically, the rest API will serve a frontend UI and the function app will provide updates to products on timer triggers.

Thanks for any guidance in advance and apologise if these are silly questions!


For #1 – I think it’s totally fine to have them both in the same (git) repository – you might be following a monorepo strategy, OR these projects might be closely related e.g. part of the same business domain/capability where you might have something like a a core Web API project (ASP.NET Core WebApi) as well as some Function App event handlers (in a Function App project) that respond to external async events and invoke the core Web API. Alternatively, if they’re completely unrelated repos and you’re not following a monorepo strategy then maybe they should be in separate repos.

For #2 – some services might be exclusive to the ASP.NET Core WebApi, some exclusive to the Function App, and some might be shared. Assuming all the code is in the same repo; for the shared dependencies, you might consider having a third ‘class library’ project in the same git repo that can be referenced by both the ASP.NET Core WebApi project as well as the Function app project. This ‘class library’ project could contain all the shared dependencies. Dependencies should be registered in the startup of both the Web Api AND the function app.

Answered By – Ryan.Bartsch

Answer Checked By – Marie Seifert (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *