6

I'm currently developing a small game that will rely on a lot Azure App Functions to execute function from time to time. I followed a tutorial on MSDN (https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs#configure-the-project-for-local-development) explaining that I had to create a new project to host a function but so far, I already have 6 different functions and I don't really want to create 6 different projects.

Moreover, all these functions (developed in JavaScript) have a lot of code in common so I created a common JavaScript file with some helper function. Now that I have multiple projects, I can't use it anymore without copy/pasting it in all projects.

Finally, to be able to correctly develop the game, all the functions must be running in parallel on my development machine and I don't really want to open 6 (or more in the future) powershell instances to host these functions.

Is there a way to host multiple functions in the same project and deploy them easily on Azure ?

ssougnez
  • 5,315
  • 11
  • 46
  • 79
  • I edited the OP – ssougnez Mar 01 '18 at 15:28
  • Can you review the approach described here? It shows how the some JavaScript code can be shared between functions. https://stackoverflow.com/questions/44612507/how-to-share-code-in-javascript-azure-functions – mybrave Mar 01 '18 at 15:32
  • You could also run them as web jobs in an app. Then it would be possible to deploy one app to azure web app with multiple projects to web jobs. – Marcus Höglund Mar 01 '18 at 15:33

1 Answers1

6

That's what Function Apps are for. Each Function App may contain multiple Functions, which will be deployed together.

You mention Javascript, but the linked tutorial is in C#. Regardless, you can put multiple functions into the same app: subfolders under the same root (where host.json file is), or static methods in the same C# project. Each function will have a separate function.json file. All functions can share the same code.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107
  • 1
    Weird, I did that and it was working on dev but when I tried to upload them to Azure, the Azure App didn't see them... I'll investigate it a bit and come back. Thanks – ssougnez Mar 01 '18 at 15:43
  • The function didn't appear in Azure because, for I don't know what reason, Visual Studio only uploaded "function.json" file and not "index.js" file... I use the comment "func azure functionapp publish" to do it and now it works... However, it uploaded the node_modules folder which seems wrong to me... Strange... – ssougnez Mar 01 '18 at 18:37