During bigquery automation i am deploying this https://github.com/firebase/functions-cron sample code. What changes i need to make in this. And not getting what is url, description. How to set url?
I have tried a BigQuery Automation using http trigger, hope it could be helpful. Here is what I did:
Create a Cloud Function that runs BigQuery query.
Keep the HTTP trigger url for step2. https://[your_project_ID].cloudfunctions.net/[your_cloud_funtion_name]
Create an App Engine App.
Since we cannot specify a Google Cloud Endpoint in the url field of a cron job, I created a handler to send the request to HTTP trigger url
Create cron.yaml that calls this handler every x minutes.
Deploy the application to App Engine.
$ gcloud app deploy app.yaml \cron.yaml
If you need more details, please post a comment and I will be happy to help.
Related
So I am switching from cloud functions to Cloud Run and I am trying to figure out how to run Event Arc locally. I know you can set up an emulator for Eventarc using Firebase Emulator but Im not sure to have it trigger one of my Cloud Run functions when I write to my local Firestore db. Can someone please let me know how this can be done?
I did see one vague answer here:
Emulation of event-driven design in Cloud Run while developing locally?
But to me this doesn't make sense given that if Im using the local DB and local functions how would a remote instance work with my local dev environment. If this is possible please let me know and how I can accomplish this. Thanks.
It's not an easy task and the team is working to make the local tests easier. For now, I can share my hack.
First of all, you have to know that eventarc is roughtly a wrapper that create several resources behind the scene, especially a PubSub topic and Push subscription to your Cloud Run service. Because of that, an eventarc event is no more than a POST request with the event content as body.
For my hack, I have a Cloud Run service, on GCP, that log the headers and body of any incoming requests. I set up an eventarc with that service as target, and I trigger an event.
I go to the logs, copy the headers and the body of the received event, and I create a curl POST request with that.
Then, when I want to test my local service, I reuse my curl POST request, and submit it to my localhost server.
I'm trying to trigger the cloud function (with trigger type - HTTP) from cloud data fusion pipeline using http sink plugin version 1.2.2. However I receive the SSL error
java.io.EOFException: SSL peer shut down incorrectly
How do I fix this?
Any help is appreciated, Thanks
To my understanding, it is currently not possible to execute a Cloud Function from Cloud Data Fusion using the HTTP sink plugin. This is because you need an OIDC token which must be generated dynamically during runtime, as they have an expiration date. This is what is explained in this post. As explaind in the post, this token should then be added to the header of the request. To generate this token, you need to run a gcloud auth print-identity-token command, which you cant do using Data Fusion.
The only workaround I see is to Publish a Pub/Sub message at the end of the pipeline to trigger this Cloud Function (however, dont take this as the solution because I would need more context on the precise use-case).
I was thinking of import my server Java code to firebase, basically replace my Dynamic web app with Jeresy and mongoDB to Firebase using hosting and functions .
I have implemented the sendWelcomeEmail and sendByeEmail with events user.created and user.deleted.
But now I want to do something more complicated.
Based on post request that comes from the mobile I want to extract the JSON data and then update the DataBase.
So I created js file with plenty of functions but now I am not sure it will actually work.
Is that the best way to implement this workflow.
The workflow goes like this.
Image is taken on the android device => extract information from image ==> upload the Json Data to the server (Firebase Hosting) => functions is been execute is response to POST request ==> extarct the data ==> save it to the Firebase Database.
Let me know if this sound ok, or I need to implent another workflow.
Thanks
Eran
The whole idea of Firebase is that your app talks directly to backend services (such as the database, or cloud storage), and you only write server-side code (with cloud functions) for functionality that Firebase doesn't provide a client-side API for.
Why don't you simply let the Android client write directly to the Firebase Database?
So I know that Cloud Functions for Firebase don't natively support cron jobs, and one have to depend on an external source to trigger an HTTP cloud function. But I don't think this will work in my case.
I have an app in which users can create competitions that end in 24 hours, thus each time a competition is created, I need to set up a timer that triggers one time after 24 hours.
Do you guys have any idea on how this problem can be approached?
At this moment the solution that the Firebase guys are providing for solving the cron issue is to use Google App Engine to deploy a server and trigger the functions via Pub/Sub hooks. Here you can find the tutorial.
Basically you have to:
Create a Cloud Function that responds to a PubSub hook.
Deploy an App Engine that will publish an event depending on the cron setup you set.
If you don't want to setup an App Engine you can use an external resource like cron-job.org that can call your HTTP Cloud Function.
I am trying to make firebase and batch work together so that I can fire push notification when something in firebase db got changed. I followed this tutorial and now i want to make them work automatically and for that i contacted with batch's and they replied me
write your own server-side code to 1. detect Firebase db changes 2. call the Batch API.
For "detect Firebase db changes" I have to create a server-side code which will track changes and call batch's api accordingly. Then follow this documentation for attaching the changed content and send it to appropriate user.
I don't know how to create the server side code. Anyone can give me a quick instructions on it or there's any tutorial related to this?
To write server-side Firebase code you can use the node.js SDK. See https://www.firebase.com/docs/web/quickstart.html (search the page for node.js).
The API is exactly the same as the regular web API except that you'll be writing it as a node.js application that can be run on the server. You can then integrate this with Batch's API.