【问题标题】:Deploy Google Cloud Functions with in Code Settings from Google Cloud SDK在 Google Cloud SDK 的代码设置中部署 Google Cloud Functions
【发布时间】:2021-03-09 01:42:02
【问题描述】:

我正在尝试使用 Google Cloud SDK 部署一个简单的功能。这是一个简单的函数:

exports.newFunction = async (msg, ctx) => {
    console.log('Hello World')
}

并根据this link 使用设置(如区域、触发器等)进行部署。

但我真的很怀念使用 Firebase 的功能,我可以在代码中使用设置(在本例中为区域和触发器)部署功能,如下所示:

exports.newFunction = functions.region('asia-east2').pubsub.schedule('every 1 minutes')
.onRun(async (context) => {
    console.log('Hello World')
}

我知道我仍然可以使用 firebase SDK 部署它,但我仍然想知道 Google Cloud SDK 是否提供此功能。有没有可能的方法?

谢谢!

【问题讨论】:

    标签: node.js firebase google-cloud-platform google-cloud-functions


    【解决方案1】:

    gcloud 无法部署使用 Firebase 提供的 firebase-functions 模块编写的函数。该模块及其 API 特定于使用 Firebase CLI 进行部署。

    如果您希望 gcloud 具有类似的行为,则必须编写自己的框架来以编程方式声明和调用函数。这可不是件容易的事。

    【讨论】:

      猜你喜欢
      • 2020-11-03
      • 2018-05-18
      • 2019-10-06
      • 1970-01-01
      • 2018-03-18
      • 1970-01-01
      • 1970-01-01
      • 2019-06-04
      • 1970-01-01
      相关资源
      最近更新 更多