Trigger cloud firestore

问题描述 投票:0回答:2

我需要有关Cloud Functions的帮助。我以前部署了用Python编写的微服务,因此获得了执行脚本的URL地址。现在,当我在Cloud Firestore中编写文档时,我想执行此URL。据我了解,我需要Cloud Functions来做,但是有人可以帮助我吗?

例如,每次我在“ temp”集合中添加文档时,我都想执行我的URL。

谢谢

google-cloud-firestore google-cloud-functions
2个回答
0
投票

[您应该从Cloud Function调用URL,例如,使用Axios库。

您会在SO上找到很多示例:https://stackoverflow.com/search?q=axios+cloud+function

如果遇到任何问题,请使用所有详细信息更新您的问题。


重要(如果您将Cloud Functions用于Firebase):

您需要加入“ Blaze”定价计划。

事实上,免费的“ Spark”计划“允许出站网络请求仅针对Google拥有的服务”。请参见https://firebase.google.com/pricing/(将鼠标悬停在“ Cloud Functions”标题之后的问号上)


0
投票

我把它放在index.js中(带有正确的网址):

exports.do_script = (event, context) => {
  return axios.get(my_url); 
};

和这个在package.json中:

{
  "name": "sample-firestore",
  "version": "0.0.1",
  "depencies": {
    "axios":"0.19.2"
  }
}

我收到此消息...无法配置触发器提供程序/cloud.firestore/eventTypes/[email protected]gcf。europe-west1.function-2)

您知道这个问题吗?

© www.soinside.com 2019 - 2024. All rights reserved.