3
votes

I was trying to deploy a PubSub function:

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 was disabled before I tried to deploy the function for the first time.
  2. It got enabled automatically.
  3. PubSub is also enabled.

Expected behavior

Since Cloud Scheduler API and PubSub have enabled for the project. ideally, there should not be any error while deploying the function. The error does mention trying after a few minutes. But it's been 24 hrs since I enabled the PubSub and Cloud Scheduler API.

Actual behavior

> 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.

Version info

node: v12.10.0

firebase-functions: 8.2.0

firebase-tools: 8.2.0

firebase-admin: 8.2.0

1
If the Firebase CLI isn't working the way you expect, contact Firebase support for assistance. support.google.com/firebase/contact/supportDoug Stevenson

1 Answers

2
votes

It finally worked. It was strange because I have enabled all the APIs necessary. The possible reasons for it were not working is that I initialized deployment during the outage and some permissions failed. So, it was being denied due to the permissions.

I was in touch with the firebase team for the last few days. We tried different things. Steps I followed to solve this issue as instructed by Firebase support:

  1. Disabled already enabled Schedular API and enabled it again in the console: https://console.cloud.google.com/apis/library/cloudscheduler.googleapis.com

  2. Created a dummy cron job by using the console: https://cloud.google.com/scheduler/docs/quickstart#create_a_job

  3. Deployed the function using Firebase CLI and it worked.