google-cloud-functions

Get execution ID for Google Cloud Functions triggered from PubSub event

荒凉一梦 提交于 2020-06-17 07:54:05
问题 For Google Cloud Functions triggered from HTTP, it is possible to retrieve the execution id by inspecting the headers of the HTTP request ( "Function-Execution-Id" ) : package p import ( "fmt" "net/http" ) func F(w http.ResponseWriter, r *http.Request) { executionID := r.Header.Get("Function-Execution-Id") fmt.Println(executionID) } However, for GCF triggered by PubSub events, I can't find how to retrieve this execution ID : package p import ( "context" ) type PubSubMessage struct { Data [

Can I populate the data from Firestore to Google Sheet whenever a new record is added using a Cloud Function?

非 Y 不嫁゛ 提交于 2020-06-17 03:16:22
问题 I am trying to build this app where I am planning to store my data in a Firestore database. My client needs the data in a Google Sheet. Can I use Cloud Function to directly populate the records from Firestore to a Google Sheet and whenever a new record will be added to the Firestore, Google Sheet will be updated automatically? Can anybody suggest any resource that can help on this topic? 回答1: Yes, you can use cloud function with Firestore trigger that is notified when your firestore document

Why am I getting sqlalchemy.exc.OperationalError when trying to connect to Google Cloud MySQL db from a local google cloud function?

半世苍凉 提交于 2020-06-17 02:51:18
问题 Here is the gist of my GCP cloud function 'app': main.py import sqlalchemy import logging import os from time import perf_counter def main(data, context): log = logging.getLogger("course_gen") db = sqlalchemy.create_engine( sqlalchemy.engine.url.URL( drivername="mysql+pymysql", username=os.environ.get("DB_USER"), password=os.environ.get("DB_PASS"), host="**.***.**.***", # this is actually the public IP of my cloud mysql instance port=3306, database="table_name" ), pool_size=5, max_overflow=2,

Startup Script in Metadata Not Running (Python, Google Compute Engine, Cloud Storage Trigger)

此生再无相见时 提交于 2020-06-16 17:26:31
问题 I have an app running on Google App Engine, and an AI running on Google Compute Engine. I'm triggering the VM instance to start on a change in a Google Cloud Storage bucket, and have a start-up script that I attempt to store in the metadata of the GCE instance. My cloud functions looks like this: import os from googleapiclient.discovery import build def start(event, context): file = event print(file["id"]) string = file["id"] new_string = string.split('/') user_id = new_string[1] payment_id =

Startup Script in Metadata Not Running (Python, Google Compute Engine, Cloud Storage Trigger)

青春壹個敷衍的年華 提交于 2020-06-16 17:25:14
问题 I have an app running on Google App Engine, and an AI running on Google Compute Engine. I'm triggering the VM instance to start on a change in a Google Cloud Storage bucket, and have a start-up script that I attempt to store in the metadata of the GCE instance. My cloud functions looks like this: import os from googleapiclient.discovery import build def start(event, context): file = event print(file["id"]) string = file["id"] new_string = string.split('/') user_id = new_string[1] payment_id =

Firebase Cloud Functions deletes nodes directly after rather than 24 hours later

牧云@^-^@ 提交于 2020-06-15 07:08:43
问题 My goal is to delete all the message nodes 24 hours after they were sent using Firebase Cloud Functions and the Realtime Database. I tried copy and pasting the answer from this post however for some reason the messages delete directly after they were created rather than the 24 hours later. If someone could help me solve this problem I would really appreciate it. I have tried multiple different answers based on the same issue and they haven't worked for me. Here is my index.js file: 'use

Firebase Cloud Functions deletes nodes directly after rather than 24 hours later

家住魔仙堡 提交于 2020-06-15 07:07:30
问题 My goal is to delete all the message nodes 24 hours after they were sent using Firebase Cloud Functions and the Realtime Database. I tried copy and pasting the answer from this post however for some reason the messages delete directly after they were created rather than the 24 hours later. If someone could help me solve this problem I would really appreciate it. I have tried multiple different answers based on the same issue and they haven't worked for me. Here is my index.js file: 'use

Unable to test locally using firebase due to CORS restriction

柔情痞子 提交于 2020-06-15 06:37:22
问题 My current usecase is simple, I just need to make a post request to a cloud function I have locally developed. The catch is, when I fire firebase serve the hosting is deployed on localhost:5000 and cloud functions are deployed on localhost:5001 These both are from different origin as port is different. Thus, when the browser sends the initial preflight request, it fails with error message Failed to load http://localhost:5001/projectname/region/sendEnquiry: Response to preflight request doesn

Flutter + firebase: Configure app to use local firebase emulator

*爱你&永不变心* 提交于 2020-06-14 05:04:25
问题 I have configured firebase to run locally for debugging using the emulator by following this link. Now I want to be able to run my app connected to the localhost for debugging triggers as well. Is there a way to achieve this by configuring my flutter app to use the localhost? My emulator is running as following: 回答1: After carefully going through the docs here, I got it working by configuring the host setting on the firestore instance: import 'package:cloud_firestore/cloud_firestore.dart';

Flutter + firebase: Configure app to use local firebase emulator

前提是你 提交于 2020-06-14 05:04:25
问题 I have configured firebase to run locally for debugging using the emulator by following this link. Now I want to be able to run my app connected to the localhost for debugging triggers as well. Is there a way to achieve this by configuring my flutter app to use the localhost? My emulator is running as following: 回答1: After carefully going through the docs here, I got it working by configuring the host setting on the firestore instance: import 'package:cloud_firestore/cloud_firestore.dart';