How should I organize a solution with multiple Azure Functions?

14,429

The MS Azure team will probably have a better answer but this is what has worked for us so far.

  • We have several function apps, each are in their own project (and solution).
  • Of those function apps, some have only a single function, others have multiple functions each in their own class/file.
  • Where we have multiple functions, it is because those functions are all related to a particular feature area of our system. Hence they work together, and for us it makes sense to maintain and deploy them as a group.
  • Other function apps are independent, containing only a single function doing a job unrelated to any other function. E.g. we have one timer driven function that crunches some numbers and sends a push notification as required.
  • Grouping the functions in this way has (so far) made sense for us as it gives us a balance between keeping our deployment relatively simple and being able to scale the 'groups' independently.

Anyway this has proved good enough for our project thus far, but I'd be interested to see if there are better ways.

Share:
14,429

Related videos on Youtube

DenaliHardtail
Author by

DenaliHardtail

Updated on October 09, 2022

Comments

  • DenaliHardtail
    DenaliHardtail over 1 year

    Where can I find guidance on organizing a Visual Studio solution with multiple Azure Functions? Specifically, how should the project be organized?

    A single Azure Function resides in a single class file. I suppose each function could be its own class file, all stored within a single project. But is this the optimal solution or do I risk future complications due to a poorly organized project / solution?

    • Mikhail Shilkov
      Mikhail Shilkov over 6 years
      You can also put multiple functions into the same static class if you wish. That's your choice, and if you find issues - you are free to change it at any time.
  • Tim
    Tim over 6 years
    One thing I wasn't clear on from your answer - are all of these function apps (in separate projects/solutions) published to the same Azure Functions instance? Or does each solution get its own Azure Functions instance?
  • Rodney
    Rodney almost 6 years
    Hi Garth: if all your functions are in a single repo - how do you deploy them individually if only a single functions changes? Or do they all get deployed with CI/CD when any code in the whole repo changes?
  • Larry Silverman
    Larry Silverman over 5 years
    If you put multiple Azure Functions in a single git repo, and deploy using automated CI/CD when new code is committed to your target branch, then all enclosed functions get updated at the same time. If using a Github account with a limited number of private repos, you may not want a repo-per-function solution. But IMHO it's best to organize based on grouping together like functions (with like environment variables or secrets) as the answerer recommended, and also to take into account the minimization of downtime of critical functions due to deployments.