Important Notes:
To deploy Firebase Functions, you need to make sure you upgrade your Firebase Pricing Plan to Blaze.
Step 1:
Setting up Node.js and the Firebase CLI
Use the Firebase doc (https:// rebase.google.com/docs/functions/get-started) if
you encounter any issues.
Node.js and Firebase CLI is needed to write functions and deploy them to the
Cloud Functions.
Install Node.js (https://nodejs.org/en/) and npm (https://www.npmjs.com/), Node
Version Manager (https://github.com/nvmsh/nvm/blob/master/README.md).
After Node.js and npm are installed, install the Firebase CLI.
Use: “npm install -g firebase-tools” command.
Step 2:
Initialize your project
An empty project containing sample code is created when you initialize Firebase
SDK for cloud functions.
Authenticate the firebase tool by running the firebase login via browser You need to create a new “MyFirebaseFunctions” empty folder
Go to the source code and find firebase-cloud-functions.zip file and extract it and go to firebase-cloud-functions > functions folder add your firebase credentials in serviceAccountKey.json, index and .firebaserc file.
Step 3:
Deploy Firebase Functions
Open powerShell from firebase-cloud-functions > functions and run command
“npm install”
“firebase login” (Select Y(yes) and It will redirect to browser and login with
google account which you used for firebase)
Now after successfully login simply run this command
“firebase deploy –only functions”
And it deploy your firebase cloud function and you can also check status in CLI
After successfully deploying the functions you can go to your Firebase Console
and check, as the functions have been deployed.
Step 4:
Watch Firebase Functions for Errors
It is possible to see the logs for each function, understand the output, and know when it gets called.
Important Notes:
To run properly, some firebase functions need the creation of indexes on
certain firestore collections.
Use the app and watch the logs for the firebase functions in the console.
If you happen to get an error of missing index, simply click on the URL of that
error, and the index will get created automatically.
There is no need to deploy functions again, but wait until the index is created, before testing the app again.