无法在Firebase云功能中部署PubSub功能

时间:2020-05-18 14:28:47

标签: firebase google-cloud-functions firebase-admin google-cloud-scheduler

我正在尝试部署PubSub函数:

exports.sendReminder 
    = functions.pubsub.schedule('0 6 * * *').timeZone('Asia/Kolkata').onRun((context) => {
        console.log('Wake up! It\'s 6AM');
        return null;
    }
);
  1. 在我第一次尝试部署该功能之前,已禁用Cloud schedular API。
  2. 该功能已自动启用。
  3. PubSub也已启用。

预期行为

由于已为项目启用Cloud Scheduler API和PubSub。理想情况下,在部署功能时应该没有任何错误。该错误确实提到几分钟后尝试。但是自从启用PubSub和Cloud Scheduler API以来已经过去了24小时。

实际行为

> eslint .

+  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
+  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (41.54 KB) for uploading
+  functions: functions folder uploaded successfully
i  functions: uploading functions in project: sendReminder(us-central1)
i  functions: creating Node.js 8 function sendReminder(us-central1)...
i  scheduler: ensuring required API cloudscheduler.googleapis.com is enabled...
i  pubsub: ensuring required API pubsub.googleapis.com is enabled...
+  scheduler: required API cloudscheduler.googleapis.com is enabled
+  pubsub: required API pubsub.googleapis.com is enabled

Error: HTTP Error: 403, Cloud Scheduler API has not been used in the project before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudscheduler.googleapis.com/overview then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

版本信息

节点:v12.10.0

firebase功能:8.2.0

firebase-tools:8.2.0

firebase-admin:8.2.0

1 个答案:

答案 0 :(得分:1)

终于成功了。很奇怪,因为我已经启用了所有必需的API。它不起作用的可能原因是我在中断期间初始化了部署,并且某些权限失败。因此,由于权限被拒绝。

最近几天,我一直与火力基地团队保持联系。我们尝试了不同的事情。按照Firebase支持的指示,我按照以下步骤解决了此问题:

  1. 禁用已启用的Schedular API,然后在控制台中再次启用它:https://console.cloud.google.com/apis/library/cloudscheduler.googleapis.com

  2. 使用控制台创建虚拟的cron作业:https://cloud.google.com/scheduler/docs/quickstart#create_a_job

  3. 使用Firebase CLI部署了该功能,并且有效。