一个项目中的多个 Azure App Function [英] Multiple Azure App Function in a project

查看:13
本文介绍了一个项目中的多个 Azure App Function的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个小游戏,它会不时依赖很多 Azure App Functions 来执行功能.我遵循了 MSDN 上的教程(https://docs.microsoft.com/en-us/azure/azure-functions/functions-develop-vs#configure-the-project-for-local-development)解释说我必须创建一个新项目来托管一个函数,但到目前为止,我已经有 6 个不同的函数,我真的不想创建 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://docs.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.

此外,所有这些函数(用 JavaScript 开发)有很多共同的代码,所以我创建了一个带有一些帮助函数的通用 JavaScript 文件.现在我有多个项目,如果不在所有项目中复制/粘贴它,我就不能再使用它了.

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.

最后,为了能够正确开发游戏,所有功能必须在我的开发机器上并行运行,我真的不想打开 6 个(或将来更多)PowerShell 实例来托管这些功能.

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.

有没有办法在同一个项目中托管多个功能并在 Azure 上轻松部署?

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

推荐答案

这就是功能应用的用途.每个 Function App 可能包含多个 Function,它们会一起部署.

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

您提到了 Javascript,但链接的教程是用 C# 编写的.无论如何,您可以将多个函数放入同一个应用程序中:同一根目录下的子文件夹(host.json 文件所在的位置),或同一 C# 项目中的静态方法.每个函数都有一个单独的 function.json 文件.所有函数可以共享相同的代码.

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.

这篇关于一个项目中的多个 Azure App Function的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆