Firebase Storage Trigger Not Working - firebase

I created a custom bucket which I use to serve content at a specific url. In Firebase I created a bucket called "images.mydomain.com" and I wanted to use this so my users can simply go to http://images.mydomain.com/imagename.jpg to access uploaded images.
I wanted to have a firebase trigger on my new bucket that does Google vision analysis on the image. Here is my function:
export const imageUploaded = functions.storage
.bucket('images.mydomain.com').object().onChange( event => {
//Cool stuff happens here
});
However, when I try to deploy the function I get this error in the console
⚠ functions[imageUploaded]: Deployment error.
Failed to configure trigger GCS Bucket: imagebucket
When I go to the function logs in Firebase I see the exact same error
Failed to configure trigger GCS Bucket: imagebucket
I also went to the Google Cloud Console to look at the functions to hopefully get some more insight on the issue. When I looked at the function, it had the correct bucket configured for the function but it had that exact same error without any explanation.
I have tried to create a new bucket using that but I get the exact same error. It seems that no matter what I do I keep getting the same error. I've tried adding permission and every It doesn't make any sense.
Does anyone know what this is about and/or how I can get this working? I had this working on the main bucket, but I really need this to work for my new bucket.
Thanks
A quick update:
I tried to deploy to my production environment (my app isn't in market yet so no one is actually using it) and it worked perfectly, the trouble is, I really need my development environment working which isn't right now.

To solve my issue I used this GitHub issue:
https://github.com/firebase/functions-samples/issues/66
Basically, there was no answer, I just had to shutdown my development project and start a new development project. Once I started a new project my functions deployed perfectly.

Related

Firebase Hosting and Github Action error "auth/invalid-api-key"

I'm using React for my project along with Firebase. Using Github Actions my code is successfully deployed to firebase.
But when I visit the hosted URL It gives me an error in the console saying
"Your API key is invalid, please check you have copied it correctly."
However when I deploy from the local system directly using firebase deploy It works fine.
I have taken the required care of my environment variables. But nothing seems to work.
It seems there is some problem while GitHub actions deploy the changes to firebase. Though all the build pass it gives me an error as stated above. Please Help.
This happen because GitHub actions don't have access to your .env on your local machine, you need to configure that on "GitHub Secrets" and put on your yml file.

Firebase deploy fails after adding second project

After adding a second project to my code using the command $ firebase use --add second-project, I get the error
There was an issue deploying your functions. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this issue persists, please contact support.
Error: HTTP Error: 404, Could not find Application "second-project".
when I run $ firebase deploy.
I have added separate targets and a web app through Firebase console for the second project.
What should I be checking to get rid of this error?
I just ran into this same exact issue as well. Leaving this here for anyone that runs into this issue in the future. What caused this error for me was a permissions error, when Firebase tried to access specific resources in Google Cloud such as Cloud Functions without the necessary IAM/service accounts in place.
This happens when you create a new Firebase project without setting the Default GCP resource location under Settings > General in the Firebase Console, which occurs when you create a new Firebase project without doing any additional setup. You can set this in the settings or this is also set when you follow the walk-through instructions for setting up services such as Firestore or Firebase Storage in the Firebase console.
Without this set, the <YOUR_FIREBASE_PROJECT_NAME>#appspot.gserviceaccount.com IAM/service account will not be created in Google Cloud (which is needed to create/access specific resources), therefore when you run firebase deploy, it will fail with the error you mentioned above.
You can also check why your firebase deploy is failing in the firebase-debug.log that is generated when running this command (that's how I found out the cause of this error). Though I think this file is deleted after the command finishes execution, so you'll have to pipe the output into a file or save it some other way.
TL;DR: Set Default GCP resource location, one way this can be done is in the Firebase Console under Settings > General.

Dev environment for Google Cloud Functions

I followed the instructions and got the hello world route working online, but I cannot see how to get to a place where I can develop, i.e. to iterate locally. This is my code so far
exports.helloWorld = functions.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
In particular I cannot access routes locally, and there is no reloading of code on save:
I tried firebase serve and then trying to reach localhost:5000/helloWorld but nothing happened at all.
firebase functions:shell led to an error being returned on the route:
"/helloWorld is not a recognized path."
I can see that from the firebase > I can run functions, but I'm trying to work with graphql so I wanted to use the graphiql web interface
And neither approach seemed to reload code when I changed things. ctrl+c, up-arrow, enter is currently my dev environment.
I'm surely missing stuff but https://firebase.google.com/docs/functions/local-emulator is difficult to follow. What am I missing?
If you've done everything correctly, firebase serve will give you the url of the HTTP function you're trying to emulate. It will contain the name of your project, the name of the Cloud region, and the name of the function. Something like this:
http://localhost:5000/YOUR-PROJECT/YOUR-REGION/helloWorld
If you don't see this URL in the output of firebase serve, then no functions are being emulated. Why that's happening is impossible to say with what you've provided here. Perhaps you're not modifying the correct index.js. Or you just forgot to save the file. Or perhaps you're running firebase serve from the wrong project location. In any event, if you're still having problems, you'll need to provide the exact steps you're taking from the moment of project creation that reproduces the problem.

why are my cloud firestore triggers not working using the GUI?

I'm trying to deploy a firestore cloud function however I'm getting the error failed to configure trigger providers. I've included some relevant screenshots.
I've also tried using different paths like '{collection}/'{document}' and 'users/farout' however only the explicit 'users/farout' was able to deploy however when i make a document 'users/farout' it doesn't print anything to the log and appears to not be working either.
My database is public read and write.
Thanks for the help.

Cloud Functions deployment failiure from Firebase

I seem to be unable to deploy Google Cloud Functions successfully.
I have created a project on Google Cloud Platform and then proceeded to link it to Firebase via the Firebase console. I select ADD PROJECT and Add Firebase to an existing project. Everything seems to link.
When I try to deploy a cloud function (the simple helloWorld that comes with installing firebase-tools) I keep getting deployment errors. This also happens when trying to deploy functions from Google Cloud Functions dashboard as well.
The error is something aboud setting up the environment.
After ttrying to rename the function to something else, I seem to have luck with deploying but then the function but there is a communication error Function load error: Error: cannot communicate with function.
I am unable to deploy functions on two of my projects, and firebase has been acting very strangely in the last few days, so can somebody please tell me if I am doing something wrong or is it a Firebase glitch
Maybe because there is an outage starting from early this morning. Check status here: https://status.firebase.google.com

Resources