google-cloud-functions

class imported but still firebase deploy fails with Cannot find module

这一生的挚爱 提交于 2020-05-17 07:38:04
问题 I have simple google cloud function declared in functions/src/index.ts import * as functions from 'firebase-functions'; import { Hero } from './hero'; var util = require('util') export const repeat = functions.https.onCall( function (data, context){ console.log(' repeat ' + util.inspect(data) + util.inspect(context)); let aHero = new Hero('Google cloud', 50); return aHero; } ); and Hero is declared in another file name hero.ts as follows in same folder as index.ts, that is functions/src/

Use user account Credential for reaching private Cloud Run/Cloud Functions

坚强是说给别人听的谎言 提交于 2020-05-17 06:12:45
问题 Here my use case. I already have a Cloud Run service deployed in private mode. (same issue with Cloud Function) I'm developing a new service that use this Cloud Run. I use the default credential in the application for the authentication. It worked on Compute Engine and on Cloud Run because the default credential is gotten from the metadata server. But, on my local environment, I need to use a service account key file for achieving this. (for example, when I set the GOOGLE_APPLICATION

Nuxt Dynamic Routing on Firebase

扶醉桌前 提交于 2020-05-16 21:46:31
问题 My Nuxt.js App has this structure: /pages/index.vue /pages/_slug/index.vue When user gets /{any_page} , it will use the path to build the page content: /pages/_slug/index.vue <template> <div> {{slug}} </div> </template> <script> import fetch from 'isomorphic-fetch'; export default { async asyncData({ params }) { return { slug: params.slug } } } </script> This works perfectly when running the Nuxt App directly via yarn dev . When I try to run this using firebase functions: $ firebase serve -

Nuxt Dynamic Routing on Firebase

情到浓时终转凉″ 提交于 2020-05-16 21:45:49
问题 My Nuxt.js App has this structure: /pages/index.vue /pages/_slug/index.vue When user gets /{any_page} , it will use the path to build the page content: /pages/_slug/index.vue <template> <div> {{slug}} </div> </template> <script> import fetch from 'isomorphic-fetch'; export default { async asyncData({ params }) { return { slug: params.slug } } } </script> This works perfectly when running the Nuxt App directly via yarn dev . When I try to run this using firebase functions: $ firebase serve -

How do import data from cloud firestore to the local emulator?

主宰稳场 提交于 2020-05-16 13:55:26
问题 I want to be able to run cloud functions locally and debug against a copy from the production data. Is there a way to copy the data that is online to the local firestore emulator? 回答1: You can use the firestore-backup-restore to export and import your production data as JSON files. I wrote a quick hack to allow for importing these JSON in the Firebase Simulator Firestore instance. I proposed a pull request and made this npm module in the meantime. You can use it this way: const

How do import data from cloud firestore to the local emulator?

久未见 提交于 2020-05-16 13:54:13
问题 I want to be able to run cloud functions locally and debug against a copy from the production data. Is there a way to copy the data that is online to the local firestore emulator? 回答1: You can use the firestore-backup-restore to export and import your production data as JSON files. I wrote a quick hack to allow for importing these JSON in the Firebase Simulator Firestore instance. I proposed a pull request and made this npm module in the meantime. You can use it this way: const

How to invoke Cloud Function from Cloud Scheduler with Authentication

99封情书 提交于 2020-05-16 06:36:09
问题 I've looked everywhere and it seems people either use pubsub, app engine http or http with no auth. Not too many people out there showing their work for accessing functions via authentication w/ oidc tokens to access google functions. I checked out: Cannot invoke Google Cloud Function from GCP Scheduler but nothing seemed to work. Documentation I followed: https://cloud.google.com/scheduler/docs/http-target-auth#using-gcloud_1 created a new service account set roles (Cloud scheduler service

GCP cloud function - Could not find kubectl on the path

佐手、 提交于 2020-05-16 04:35:18
问题 i'm writing this Google Cloud Function (Python) def create_kubeconfig(request): subprocess.check_output("curl https://sdk.cloud.google.com | bash | echo "" ",stdin=subprocess.PIPE, shell=True ) os.system("./google-cloud-sdk/install.sh") os.system("gcloud init") os.system("curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/linux/amd64/kubectl") os.system("gcloud container clusters get-credentials **cluster name** --zone us-west2-a --project **project name**") os

Calling Cloud Function from App Engine runtime Python 3.7 [duplicate]

冷暖自知 提交于 2020-05-15 09:08:10
问题 This question already has answers here : Post JSON using Python Requests (6 answers) Closed last year . I have an App Engine service, running Python 3.7, that needs to call and get a response from one of my Cloud Functions via the https.oncall trigger. I thought I could do so with the following: import logging from sys import exit import firebase_admin import requests import google.cloud.logging client = google.cloud.logging.Client() client.setup_logging() firebase_admin.initialize_app()

Firebase emulator return empty data whereas working fine after deploying

北城余情 提交于 2020-05-15 08:08:13
问题 I have a written a very basic API which will return the services. I tried to run this API in emulator but it return the empty data { "status": "success", "statusCode": 200, "message": "Services retrieved", "data": [] } I have setup the firestore, functions and database emulators. And I am using "firebase-admin": "^8.10.0", "firebase-functions": "^3.6.0" Any idea why the data response is empty ? EDIT This is my method to call the service export const activeServices = functions.https.onRequest(