Azure Functions 使用 import 而不是 require

Azure Functions use import instead of require

使用 import 而不是 require 的配置要求是什么?

我正在使用函数运行时 v2。 我尝试将节点升级到 v10.12.0 但在导入时仍然出现此错误 工作人员无法加载函数存储:'SyntaxError: Unexpected token {'

我在 local.settings 和 package.json 中将节点版本设置为 10.12.0。 我的功能是这样设置的...

module.exports = async function(context, queueMessage) {
import { cosmos } from "@azure/cosmos";
import { updateChat } from "./channels/chat/newChatMessage";
import { updateAttributeStatus } from 
"./channels/attribute/updateAttributeStatus";
import { documentRequest } from "./channels/document/documentRequest";
...

A​​zure Functions 支持哪个版本的节点并支持导入?如果可以,我该如何设置?

谢谢, 唐尼

According to the docs V2 支持这些版本:

Active LTS and Current Node.js versions (8.11.1 and 10.6.0 recommended). Set the version by using the WEBSITE_NODE_DEFAULT_VERSION app setting.

所以必须在Application Settings as explained here中设置节点版本。

关于 import 与 require 的使用,,因此我认为还不能在 Azure Functions 中使用它。

我可能会转而使用 TypeScript 并在上传之前对其进行转换(您可以在 GitHub 上找到一些关于如何开始使用它的示例)。