Failure to Deploy Cloud Function When Using Wildcard in Trigger

杀马特。学长 韩版系。学妹 提交于 2020-06-17 08:57:04

问题


I'm trying to deploy a cloud function that will trigger whenever a document is added to a particular collection as below:

const admin = require("firebase-admin");
const functions = require("firebase-functions");

const Firestore = require("@google-cloud/firestore");
const firestore = new Firestore({ projectId: config.projectId });

admin.initializeApp(config);

exports.checkCapacity = functions.firestore.document("gran_canaria/las_palmas_1/miller_pendientes/{albnum}")
  .onCreate(async (snapshot, context) => {});

However this throws the Deployment failure error:

Failed to configure trigger providers/cloud.firestore/eventTypes/document.create@firestore.googleapis.com (gcf.us-central1.checkCapacity)

The error clears if I remove the wildcard and change the reference to:

"gran_canaria/las_palmas_1/miller_pendientes/albnum"

I've attempted changing the method to onWrite(), deleting and re-deploying the function and checking the cloud status at https://status.cloud.google.com/ but can't find any solutions.


回答1:


I have been able to deploy successfully a Cloud Function with a trigger on an onCreate event on my Cloud Firestore.

I have been successful by imply using the provided template in the Console UI when creating the Cloud with the following:

The index.js used is the sample provided by GCP when created the function, which simply prints to the logs which document triggered the change.

Looking at the documentation in Firestore, I see that you probably used the samples provided there, so maybe using the above settings will make it work for you.



来源:https://stackoverflow.com/questions/57789535/failure-to-deploy-cloud-function-when-using-wildcard-in-trigger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!