簡體   English   中英

無法在 firebase 雲功能中部署 PubSub function

[英]Not able to deploy PubSub function in firebase cloud functions

我試圖部署一個 PubSub function:

exports.sendReminder 
    = functions.pubsub.schedule('0 6 * * *').timeZone('Asia/Kolkata').onRun((context) => {
        console.log('Wake up! It\'s 6AM');
        return null;
    }
);
  1. 在我第一次嘗試部署 function 之前,雲計划 API 被禁用。
  2. 它自動啟用。
  3. PubSub 也已啟用。

預期行為

由於 Cloud Scheduler API 和 PubSub 已為該項目啟用。 理想情況下,部署 function 時不應出現任何錯誤。 該錯誤確實提到了幾分鍾后嘗試。 但是自從我啟用 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 工具:8.2.0

火力基地管理員:8.2.0

它終於奏效了。 這很奇怪,因為我啟用了所有必要的 API。 它不起作用的可能原因是我在中斷期間初始化了部署並且某些權限失敗。 因此,由於權限而被拒絕。

前幾天我一直在聯系 firebase 團隊。 我們嘗試了不同的東西。 我按照 Firebase 支持的指示解決此問題的步驟:

  1. Disabled 已啟用 Schedular API 並在控制台中再次啟用它: https://console.cloud.google.com/apis/library/cloudscheduler.googleapis.Z4D236D9A2D102C5ZFE6AD1EC5C

  2. 使用控制台創建了一個虛擬 cron 作業:https://cloud.google.com/scheduler/docs/quickstart#create_a_job

  3. 使用 Firebase CLI 部署了 function 並且它工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM