typescript - Azure Functions 可以是 Typescript 中的类吗?

标签 typescript azure azure-functions

使用 .NET,这是编写 Azure 函数的默认方式,但使用 Typescript/NodeJS 可以完成类似的操作吗?

我正在考虑一些类似的事情:

// MyAzureFunction.ts

class MyAzureFunction implements SomeRunableInterface {
  async run(context, res) {}
}

module.exports = new MyAzureFunction()

最佳答案

我能够解决该问题,请按照以下步骤操作

  • 打开azure门户,在搜索栏中输入功能应用,如下所示

enter image description here

  • 点击功能应用后,点击创建,如下所示

enter image description here

  • 点击创建后,会打开一个页面,需要填写订阅资源组函数应用名称、< strong>运行时堆栈、版本区域,然后单击查看和创建,如下所示

enter image description here

  • 在 Azure 门户中创建函数应用后,现在可以在“Visual Studio Code”(VS 代码)中使用 typescript 创建 HTTP 触发器
  • 打开“VS code”,然后转到 VS code 中的 azure 图标,然后转到工作区,单击+并选择创建功能它将弹出一个窗口以创建新文件夹,单击 引用下图

enter image description here

  • 它将打开一个命令面板,选择如图所示的 Typescript,然后单击输入

enter image description here

  • 选择HTTP 触发器 enter image description here

  • 之后,在下一个字段中选择 HTTP 触发器,然后单击输入,然后在下一步中选择匿名

  • 创建HTTP触发器后,我们需要将其部署到Azure门户中的函数应用程序中,该函数应用程序在创建HTTP触发器之前已创建

  • 现在打开“VS code”并单击下图所示的部署图标

enter image description here

  • 单击部署到函数应用后,它将打开一个命令选项板,选择订阅 ID,然后选择要添加 HTTP 触发器的函数应用,然后单击 <强>输入。从输出中的“VS代码”成功部署后,您将看到下图

enter image description here

  • 检查 Azure 门户中部署的 HTTP 触发器,如下所示

enter image description here

关于typescript - Azure Functions 可以是 Typescript 中的类吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74160257/

相关文章:

c# - 保护 Azure 功能的方法有哪些

javascript - Angular - 从 'then' 内部返回值

javascript - this.router.events 未在 Angular 中首次加载

azure - 使用 AzureDevOps 更新 Azure 上托管的 Sitecore 应用程序

c# - Azure 应用程序服务 Windows 容器 - 使用安装存储将文件上传到文件共享错误

azure - 部署的隔离功能应用程序返回 404

angular - 在样式标签 Angular 2 中使用变量

javascript - 无法将 useState 与 typescript 一起使用(找不到名称 'useState' )

azure - 如何在 Azure Pipelines Pull 请求中重新部署版本?

visual-studio - Visual Studio 2019 重新下载 Azure Function CLI 工具