41

I am create API with firebase via this tutorial here.

On I run:

firebase deploy

I get this error on the command line:

HTTP Error: 400, Billing account for project '381106441303' is not found. Billing must be enabled for activation of service(s) 'cloudbuild.googleapis.com,containerregistry.googleapis.com' to proceed.

Please show me how to fix this problem!

Doug Stevenson
  • 236,239
  • 27
  • 275
  • 302
Hao
  • 411
  • 1
  • 4
  • 4
  • Looks like [you'll have to buy a license](https://firebase.google.com/support/faq#expandable-10) – digijay Sep 17 '20 at 06:53
  • @digijay but in this tutorial, the author didn't say that, and response in the following is positive. – Hao Sep 17 '20 at 07:09
  • According to what is said in the link, it was free until Aug. 2020. The turorial is from 2018. – digijay Sep 17 '20 at 07:25

9 Answers9

76

If you just want to finish a tutorial, just change Node version from 10 to 8 in package.json

"engines": {
  "node": "8"
}

This will now work, but eventually after February 15, 2021 deployment of Node.js 8 functions will no longer be allowed. So, if you want to use cloud functions after this date you must be on Blaze pay-as-you-go billing plan.

The1993
  • 455
  • 1
  • 3
  • 19
  • Firebase will mention any methods after deploy as "deprecated" as well. Thank you for the details and work around for now! – Michael DiCioccio Oct 24 '20 at 21:57
  • Just as a remark, if you are using a different node version in your local machine it will reject the deploy as well. So, if it rejects it, switch to node version 8 only while deploying and it will be fine. – Mateo Guzmán Nov 05 '20 at 09:03
  • Error: functions.runtime value is unsupported. Valid choices are: nodejs10, nodejs12, and nodejs14. – Eduardo Cuomo Mar 10 '21 at 02:45
25

If you just want to test or follow the tutorial, see this answer.

If you want to use at the real projects, follow these steps:

  1. Enable Billing for your projects
  2. Enable Cloud Build API
  3. Enable Container Registry API

From Firebase FAQ:

From updates on August 17, 2020, Cloud Functions for Firebase will rely on some additional paid Google services, so You have to add billing, enable Container Registry API and Cloud Storage API to use it.

See more: Cloud Functions pricing

Edit: Following these steps automatically upgrades your Project plan to Blaze-Pay as you go. - Thanks to @Abhimanyu

Albert Khang
  • 371
  • 2
  • 11
  • 1
    Great answer. I was confused because I should be able to deploy functions without upgrading to a paid "Blaze" plan on firebase. I just needed to enable billing for my "spark" project through the above GCP billing interface. No need to go to Blaze for my demo projects. – Matthew Rideout Nov 03 '20 at 22:56
  • 2
    Note: Following these steps automatically upgrades your Project plan to Blaze-Pay as you go. – Abhimanyu Nov 14 '20 at 06:13
  • This is the way to go as newer versions of the firebase sdk (since Version 9.0.0 - 14 July, 2020) no longer support node.js 8 runtime. You can't even push a new project to the cloud. You can try downgrading to the old version but don't get to used to it, It's scheduled to be pulled in early 2021. – mkturner Nov 14 '20 at 23:45
  • Correct way to do this. – chazefate Nov 26 '20 at 09:17
  • Surprisingly... ONLY Albert's links worked... When I attempted to add the APIs manually... I received a server error. Came back here and copy/pasted the links above... and it worked flawlessly. – mystic cola Jan 28 '21 at 10:00
10

The tutorial you're following is very old. Cloud Functions now requires an active billing account. You will need to add one, even if you don't expect to exceed the free allowance.

See also:

Consider contacting the author of that article to tell them that they should update their article to be more accurate.

Doug Stevenson
  • 236,239
  • 27
  • 275
  • 302
8

It works fine for me you don't have to pay I'm using firebase free tier

1st Downgrade node version from 10 to 8 on package.json

"engines": {
"node": "8"
  }
  1. firebase deploy

  2. you'll get + Deploy complete! message above that you'll see

    + functions[helloWorld(us-central1)]: Successful update operation.

  3. this us-central is my project hosted region in your case may be differ

    prefix to this region [helloWorld is my exported function name your case it may differ get this information from your terminal by firebase deploy command

  4. After that your hosted project link will be

https://yourregion-firebaseprojectname.cloudfunctions.net/yourexportedfunctionname 

(exported function name) which is helloWorld

4

You can lower the node version from 10 to 8, but you should upgrade your plan to 'Blaze' as it has the whole free plan, It will only charge you if you pass the free plan

The1993
  • 455
  • 1
  • 3
  • 19
3

You can try this :

firebase deploy --only hosting

Full docs

Somrlik
  • 584
  • 3
  • 13
  • thanks! It's nice to know you can specify any of the firebase products with the `--only` switch: `hosting`, `database`, `storage`, `firestore`, `functions` – BizzyBob Dec 03 '20 at 01:58
1

This is a example of scheduler , but this will not work in free account . Billing must be enabled for activation of service(s) 'cloudscheduler.googleapis.com' to proceed.

import * as functions from 'firebase-functions';
import {db, notificationSentEvent, deviceData} from './init';

export const dailyDelete = functions.pubsub.schedule( '10 1 * * *' ).onRun(context => {
    console.log('At 01:10');
})
1
  1. Go to firebase console
  2. Go to usage and billings
  3. Change plan from Free to Pay as you go
0

I get an error also!

How you fix the error is: go to https://console.firebase.google.com/project/your_firebase_project/usage/details website and then follow the onscreen instructions.

Then run the command in the Linux home directory on the Linux terminal:

firebase deploy

and it works!

sage
  • 1
  • 2