Google Cloud Functions 2nd Generation with Firebase Database trigger - firebase-realtime-database

I'm trying to update my function from cloud function 1st generation (java 11) to 2nd generation. Apparently some changes imply that the old implementation of the functions through Cloud CLI doesn't work on the new cloud functions. The old trigger was setting by this command:
--trigger-event providers/google.firebase.database/eventTypes/ref.create \
--trigger-resource projects/_/instances/root/message/{message_id}
Is still possible to run a function on "OnCreate" trigger from firebase database? It looks like it could be reach with the EventArc, but I don't find anywhere how to do that. Someone is already doing that or can clarify this?

As per the comment of #DazWilkin, there's an existing public issue tracker for this issue. As per the contents of the issue (as of March 18, 2022): "Cloud functions team identified the issue: the flag doesn't support the event because it only supports PubSub and GCS events, the team is going to change the message to be more specific."
On this note, there's a preview limitation stated in the official Firebase documentation (as of March 29, 2022):
Cloud Functions (2nd gen) offers Pub/Sub, Cloud Storage and Audit Log events through Eventarc. Additional events for Firestore, Firebase RTDB, Analytics, and Auth are planned.

Related

Firebase cloud function dart kill all functions

I am searching for preventing attacks like Ddos, I am not sure I came across a solution.
Case 1
in which from every request putting a increment value in firestore database. After certain value such as 100000 a cloud function will trigger which will destroy / deactivate all my cloud functions.
Case 2
Is there any easy way using if else in cloud functions.
I am new to Firebase cloud functions
I am writing cloud functions in dart
Is there any way to write security rules for calling function
Is there any way to limit invocations
Can cdn or another service integration help in this situation. I dnt want surprise bill
First of, see this documentation on the guidelines you should follow to avoid security attacks in Firebase.
in which from every request putting a increment value in firestore database. After certain value such as 100000 a cloud function will trigger which will destroy / deactivate all my cloud functions.
Unfortunately, this is not how a managed service works. Cloud Functions can only be triggered when invoked or during a response to an event. If there's no traffic, then the function is not running. It's not possible to deactivate them.
You can however, list all you functions and delete them one-by-one by using Cloud Functions Client Library and method deleteFunction().
Is there any easy way using if else in cloud functions.
For this question, are you referring to conditional statements or on how a traffic is redirected?
I am new to Firebase cloud functions I am writing cloud functions in dart
Currently, there is no official way to deploy a function running in Dart Runtime, though there are community supported projects that allow you to run Dart functions on other environments.
Node is the only runtime being supported in Cloud Function for Firebase as of the moment. See documentation here.
Is there any way to write security rules for calling function
Firebase security rules are for Cloud Firestore, Realtime Database, and Cloud Storage. See this SO that shows how to protect HTTP functions using auth id tokens and database rules.
Additionally, in this documentation, you can find how to setup security rules in your Firebase project. Sample scripts can be found here.
Is there any way to limit invocations
You can find a similar SO question here on limiting invocations in Firebase Cloud Functions. Additional details regarding Quotas and Limits can be found here.
Can cdn or another service integration help in this situation. I dnt want surprise bill
CDNs can help you bring down costs due to caching behavior, however it is not the complete solution to avoid surprise bills. One way to avoid this is to setup budget alerts to send email notifications whenever your project exceeds (or about to exceed) the set spend threshold. See documentation on Avoiding surprise bills here.

Make a Firebase Database call every day once

I got an iOS app and I'm storing values in Firebase per user.
Every 24 hours I need to reset those values in Firebase automatically, even when the user does not open the app.
Is it possible to do this in the app itself or do I need to write cloud code?
You can´t run this type of code when your application is not active. If you need to reset the data every 24 hours even when the user does not open the app it´s better to create a job in your backend to execute this type of action and separate this logic from the application.
An example of a job in your backend can be Cloud Functions for Firebase, since you´re already using Firebase.
Cloud Functions for Firebase lets you automatically run backend code
in response to events triggered by Firebase features and HTTPS
requests. Your code is stored in Google's cloud and runs in a managed
environment. There's no need to manage and scale your own servers.
Yes there is a way to do so. Firebase gives a cloud function support where you can write and read data whenever you want. just need to run the code ones with what type of data you want to update and then set a timer of 24 hours to change the existing data. Then you are ready to go.Here is the link of Firebase Docs for cloud functions. Go through it for more deeper understanding
Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features
and HTTPS requests. Your code is stored in Google's cloud and runs in
a managed environment. There's no need to manage and scale your own
servers.
Typical use cases might fall into these areas:
Notify users when something interesting happens.
Perform Realtime Database sanitization and maintenance.
Execute intensive tasks in the cloud instead of in your app.
Integrate with third-party services and APIs.
Check this Use case:
What Can I Do with Cloud Functions: Use case

Pushing data from iOS to Google Cloud BigQuery

I am new to Google Cloud Platforms and not quite sure with the whole architecture but what I am trying to achieve is to save some data to Google Cloud from an iOS application and do some analytics work on this data using Google Cloud Products, such as: Dataproc and Datalab. From what I read so far I would need to create a dataset in Google Cloud BigQuery and create a table in it. I have done this using the Google Cloud Web UI but now I want to populate the table from my iOS app. I can't seem to find how to do that.
The most painless route would be to wire up Firebase Analytics and then turn on its daily log export to Big Query, as described by Google in the walkthrough Importing Firebase Analytics Data into BigQuery. Google maintains the entire analytic export stack for you then, seeing as they also maintain Firebase. The downside is that the analytics export happens only daily.
Alternatively, you'd be looking at using the Big Query REST API to upload data, as documented by Google in their Loading Data with a POST Request how-to guide. The iOS tooling for that would be your usual NSURLSession and NSURLDataTask APIs, or whatever abstraction you prefer that's built atop them.
Google does maintain a collection of iOS-native APIs, but unfortunately, Big Query is not included amongst the supported APIs as of May 2017. There are native Big Query clients for Go, C#, and Java, amongst others. So you could use your own API for upload to a server you control, and then use one of those client APIs serverside to implement the actual Big Query integration, if you wished.

how to store data on Firebase - Delphi XE 10

What is the best way to connect to Google´s Firebase DBaaS from Embarcadero Delphi XE 10 ?
I am not sure how to do it from AnyDAC.
Or if exists a component out there (i coundnt find one on search)
Any help?
thank you
Firebase was acquired by Google and now makes available many tools and features (Cloud Messaging, Authentication, Realtime Database, Storage, Hosting etc...)
If you are looking for a service that store and sync app data in realtime, the Realtime Database it's for you. Realtime Database: "A cloud-hosted NoSQL database. Data is stored as JSON, synced across connected devices in milliseconds, and available when your app goes offline." . Firebase provides SDK library for Android, iOS and Web (Javascript). In addition makes available a REST API interface and, as Robert Love said in previous post, Firebase4Delphi (I wrote it) library provides access to the REST API in Delphi. Here there is an example of how to use library.
In the meantime a new open source library is available on GitHub for Firebase, Firestore, Firebase Storage and Firebase Functions:
Get more information on https://github.com/SchneiderInfosystems/FB4D
There is an open source project called Firebase4Delphi. It provides access to the REST API in Delphi.

How can I auto-post updates to my Page's stream on Google Plus?

So, I've written some code to analyze a commit from my SVN repository and I have Jenkins running it. I'd like to figure out a way to have Jenkins post to my Google Plus stream. For reference, you can view the last couple of posts here: https://plus.google.com/+Casual-dev/posts
I am running into the issue where I cannot login without a real person behind the console and it's a headless server. I'd like to just write a java app and have it either login and share to Google Plus directly or send an email somewhere that will be posted to Google Plus.
Does anyone have an example of a headless login/post or a non-SMS based method of posting to Google Plus?
Take a look at HootSuite's API, which should allow you do what you want. The Google+ write API is only available to a limited number of providers, and HootSuite is one of them.

Resources