使用 Javascript 作为 http 触发语言的 Azure 函数 - 通过 VS Code 生成时缺少 function.json

问题描述 投票:0回答:1

我使用 Javascript 作为平台语言创建了 Azure Function。它工作和部署得很好。但是,它缺少 function.json。它是否会像我看到其他帖子那样生成。我之所以问这个问题是因为我需要添加其他依赖项(导入模块)来编写连接到 Azure Cosmo DB 的代码作为示例。

请让我指出正确的路径,因为我尝试四处搜索,但没有找到带有 Javascript 的 Azure Function,如果我确实找到了它们,它们是自动创建的 function.json 的旧帖子。

提前致谢。

我使用 VS Code 创建了一个样板,但缺少 function.json。这是预计会产生的吗?它已在其他教程和帖子中显示。

javascript node.js azure function visual-studio-code
1个回答
0
投票

我在 VS Code 中使用运行时堆栈 javascript 创建了 Http 触发函数。

  • 在创建函数时,如果 model4 采用则不会给出
    function.josn
    。如下:

enter image description here

  • 创建函数时将采用函数模型3。它将生成
    function.json
    文件。检查下面:

enter image description here

  • 按照上面的模型创建函数后,如下所示:

enter image description here

function.json:

{
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ]
}

要使用以下命令安装最新版本的 azure function-core-tools:

npm install -g azure-functions-core-tools@latest

© www.soinside.com 2019 - 2024. All rights reserved.