I have a vue project. It has a firebase function. I was able to deploy the function to google cloud once. But trying to deploy it later, I find I'm unable to.
Here is the console output from Visual Studio Code:
PS C:\udemy\vue-firebase\geo-ninjas> firebase deploy --only functions
=== Deploying to 'g-s-geo-ninjas'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
functions# lint C:\udemy\vue-firebase\geo-ninjas\functions
eslint .
functions: Finished running predeploy script.
i functions: ensuring necessary APIs are enabled...
functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (38.34 KB) for uploading
functions: functions folder uploaded successfully
i functions: updating Node.js 6 function checkAlias(us-central1)...
! functions[checkAlias(us-central1)]: Deployment error.
Error setting up the execution environment for your function. Please try > deploying again after a few minutes.
Functions deploy had errors with the following functions:
checkAlias
To try redeploying those functions, run:
firebase deploy --only functions:checkAlias
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
PS C:\udemy\vue-firebase\geo-ninjas>
When I look at the logs in the firebase console, I see this:
{"#type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":13,"message":"INTERNAL"},"authenticationInfo":{"principalEmail":"junk.mail291276#gmail.com"},"requestMetadata":{"requestAttributes":{},"destinationAttributes":{}},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/g-s-geo-ninjas/locations/us-central1/functions/checkAlias"}
I widdled down my checkAlias function to the bare minimum that would function:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.checkAlias = functions.https.onCall(data => {});
...and this still won't deploy.
I've ran eslint and this has no lint errors. When I run this locally, it works.
Why would I be getting these errors when trying to deploy my firebase function?
Related
I'm using the firebase-tools CLI to deploy firebase functions. I'm trying to deploy a function using firebase deploy --only functions:functionName.
This is in an existing project. The functions are located in /functions/index.js.
Up until a few hours ago, deploying worked fine. But now when trying to deploy a new function I get the following:
i deploying functions
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
+ functions: required API cloudbuild.googleapis.com is enabled
+ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing functions directory for uploading...
+ Deploy complete!
But it clearly does not even upload anything or deploy a function. Trying to deploy an existing function, I get The following functions are found in your project but do not exist in your local source code:
I'm a bit baffled as to how this seems to have "broken". Even looking at the git for the project there have been no changes to any config files or anything, other than writing a new function. I have not updated any packages since last deploying, and have tried the previous version of firebase-tools as well as the latest version.
Deploying a different function to a different project in the same manner is successful.
Turns out, I had created a file called functions.js in the project root directory (not /functions directory) and it appears firebase-tools was looking to that (empty) file for its functions, instead of the functions directory. Strange, and no kind of error message since I guess the file it thought it was looking for did exist.
This question already has answers here:
Is Cloud Functions in Firebase Free or Not (Cloud Functions deployment requires the pay-as-you-go (Blaze) billing plan)
(8 answers)
Closed 2 years ago.
(base) macbooks-mbp:functions macbook$ firebase deploy
=== Deploying to 'fir-project1-e0b25'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions# lint /Users/macbook/fireCast/functions
> tslint --project tsconfig.json
Running command: npm --prefix "$RESOURCE_DIR" run build
> functions# build /Users/macbook/fireCast/functions
> tsc
✔ functions: Finished running predeploy script.
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
**⚠ functions: missing required API cloudbuild.googleapis.com. Enabling now...**
✔ functions: required API cloudfunctions.googleapis.com is enabled
Error: Cloud Functions deployment requires the pay-as-you-go (Blaze) billing plan. To upgrade your project, visit the following URL:
https://console.firebase.google.com/project/fir-project1-e0b25/usage/details
For additional information about this requirement, see Firebase FAQs:
If you read the error message carefully, it tells you what you need to do:
Cloud Functions deployment requires the pay-as-you-go (Blaze) billing plan. To upgrade your project, visit the following URL:
https://console.firebase.google.com/project/fir-project1-e0b25/usage/details
Cloud Functions no longer allows you to deploy functions targeting the nodejs 10 runtime without a billing account active on the project.
See also: Is Function Cloud in Firebase Free or Not (Cloud Functions deployment requires the pay-as-you-go (Blaze) billing plan)
I am integrating CI/CD for deploying my firebase functions.
firebase use PROJECTID --token FIREBASE_TOKEN
firebase deploy --token FIREBASE_TOKEN --non-interactive
Now whenever a function is deleted from index.js, it throws the following exception.
Error: The following functions are found in your project but do not
exist in your local source code: httpSeeding(us-central1) Aborting
because deletion cannot proceed in non-interactive mode. To fix,
manually delete the functions by running: firebase functions:delete
httpSeeding --region us-central1
Is there a way in the non-interactive mode where a deleted functions are removed from the console without running firebase functions:delete httpSeeding??
Run deploy with -f option, it should delete extra functions in non-interactive mode
firebase deploy --token FIREBASE_TOKEN -f
From the docs available by running firebase help deploy, we see following option:
-f, --force delete Cloud Functions missing from the current working directory without confirmation
Just run the same deploy command from your shell. It will automatically delete functions that are missing from your source.
Also you can delete functions directly from the Cloud console.
I'm in the process of uploading some Cloud Functions for Firebase via the Firebase CLI. I have my functions folder setup and everything is correct. :I actually use this exact functions folder in another project but for whatever reason in this particular project, when I run firebase deploy --only functions, I get this:
i deploying functions
i functions: ensuring necessary APIs are enabled...
i runtimeconfig: ensuring necessary APIs are enabled...
✔ runtimeconfig: all necessary APIs are enabled
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (972 B) for uploading
✔ functions: functions folder uploaded successfully
i starting release process (may take several minutes)...
i functions: updating function getUserByEmail...
⚠ functions[getUserByEmail]: Deploy Error: Failed to initialize a region
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Does anyone know what this error means?
Thanks in advance!
I'm having trouble doing firebase deploy --only functions for an app on Blaze plan.
I have the latest firebase-tools CLI (v 3.5.0).
I get the following error:
=== Deploying to 'myapp1234'...
i deploying functions
i functions: ensuring necessary APIs are enabled...
i runtimeconfig: ensuring necessary APIs are enabled...
✔ runtimeconfig: all necessary APIs are enabled
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (1.29 KB) for uploading
✔ functions: functions folder uploaded successfully
i starting release process (may take several minutes)...
i functions: updating function myFunc...
⚠ functions[myFunc]: Deploy Error: Failed to initialize a region
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
I've retried this every half hour for the past 12 hours, thinking there's an outage. The firebase status page shows all green.
Ok, here's what I found, a little weird:
firebase list shows all the firebase projects you have access to, BUT they are not already available (i.e. added as alias to your current folder project).
Even if the firebase-tools CLI allows you to do firebase deploy --project myproject1, if you do not have myproject1 declared in .firebaserc => it will fail with the weird region error above.
To fix this, I found that there are 2 options:
firebase use --add (will trigger an interactive list)
firebase use myproject1
=> and then firebase deploy --project myproject1 will work (with or without the optional --only functions)