google-cloud-functions

Invoking a Google Cloud Function from a Django View

試著忘記壹切 提交于 2021-01-29 03:34:58
问题 I have created a Google Cloud function that can be invoked through HTTP. The access to the function is limited to the Service account only. If I had a Django View which should invoke this function and expect a response? Here is what I have tried 1) Before starting Django I set the environment variable export GOOGLE_APPLICATION_CREDENTIALS 2) I tried invoking the function using a standalone code, but soon realised this was going nowhere, because I could not figure out the next step after this.

Get the requesting URL in Callable Firebase Functions

六月ゝ 毕业季﹏ 提交于 2021-01-29 03:06:13
问题 I have a service that shares html to multiple client web sites. I need to know The URL of where the request is coming from. The client will add a custom script to their website and the script will load Firebase SDK and call one of my callable firebase functions. exports.testFunction = functions.https.onCall(async (data, context) => { //How do you access the requesting URL? console.log(context.rawRequest.originalUrl) "/" console.log(context.rawRequest.url) "/" }) Thank you, 回答1: HTTP requests

Cannot access cloud SQL from firebase cloud functions in a different project

不羁的心 提交于 2021-01-29 00:38:07
问题 I have two GCP projects(one of them is a firebase project), and I am trying access a cloud SQL instance on one project from the other project's firebase cloud functions. I have followed the instructions here: https://cloud.google.com/sql/docs/mysql/connect-functions On this instruction, it says When connecting resources in two different projects, make sure that both projects have enabled the correct IAM roles and have given the service account the correct permissions. and I am not entirely

How does Firebase Firestore emulator work?

早过忘川 提交于 2021-01-28 21:51:13
问题 So far I've been using Firebase Hosting and Functions emulators. But now I'm writting a function that will run based on a Firestore trigger, so I'm looking into the Firestore emulator for development. But how does it work? Does it mimics Firestore completely? Will I be able to read my current Firestore data that it's saved on server? And what if I update, create or delete change documents, will I be really changing them in my real data as well? I'll run it with: firebase emulators:start -

Recover Cloud functions default service account with the undelete POST call

这一生的挚爱 提交于 2021-01-28 14:11:38
问题 I have used Google Cloud Functions for quite a long time, with no real authentication problem for now. Today I meet this error while deploying a new function ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[Bad Request], message=[Default service account 'PROJECT-ID@appspot.gserviceaccount.com' doesn't exist. Please recreate this account (for example by disabling and enabling the Cloud Functions API), or specify a different account.] I tried several things : disable/enable

How do I do a GET for Firebase.functions().httpsCallable?

喜夏-厌秋 提交于 2021-01-28 12:50:38
问题 How do I do a GET for Firebase.functions().httpsCallable? I keep receiving a POST error 404 but this is a GET request to my server. Should I pass in nothing or there is something to change this httpsCallable to get function? Client let updateWorkshop = Firebase.functions().httpsCallable('api/update/workshop'); updateWorkshop({/* nothing */}) .then(res => { console.log(res); }, err => { console.log(err); }) Server app.get('/v3/update/workshop', asyncMiddleware( async (req, res, next) => { let

How do I do a GET for Firebase.functions().httpsCallable?

雨燕双飞 提交于 2021-01-28 12:48:29
问题 How do I do a GET for Firebase.functions().httpsCallable? I keep receiving a POST error 404 but this is a GET request to my server. Should I pass in nothing or there is something to change this httpsCallable to get function? Client let updateWorkshop = Firebase.functions().httpsCallable('api/update/workshop'); updateWorkshop({/* nothing */}) .then(res => { console.log(res); }, err => { console.log(err); }) Server app.get('/v3/update/workshop', asyncMiddleware( async (req, res, next) => { let

gcp - Trigger Cloud Function on database insert?

非 Y 不嫁゛ 提交于 2021-01-28 12:23:41
问题 Not sure how to search this; I'm looking for a way to trigger a Cloud Function whenever a new row is inserted into a database in Cloud SQL. The search for "google cloud function events" (or "triggers") turn up Firebase results, which is not what I want. There are a series of Cloud Functions that receive data and transform it according to the clients' needs; in the end, after some manipulation, that data ends up in a table. Is there an event I can listen to so I can access the newly inserted

Google Cloud Functions: monitor HTTP status codes [closed]

不问归期 提交于 2021-01-28 11:20:31
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last month . Improve this question I want to setup Cloud Monitoring to alert me each time my Cloud Function responds with 4xx / 5xx HTTP status codes. Please let me know how to implement this from Cloud Console. 回答1: You can use Cloud Logging for this. Go to the Cloud Logging page and filter your logs Then

Does Firebase Admin SDK perform any caching?

人走茶凉 提交于 2021-01-28 10:08:18
问题 I've been using firebase with cloud functions recently and this question popped into my mind. If in my cloud function, using the Firebase Admin SDK, perform multiple reads to the same document in a single function call, will it count as multiple reads in the database or will it cache the data? Example: await admin.firestore().collection("users").doc("user_id_here").get(); await admin.firestore().collection("users").doc("user_id_here").get(); await admin.firestore().collection("users").doc(