标签: google-cloud-functions

从我之前部署的firebase控制台获取代码

我在nodejs中创建了firebase函数,并在firebase上部署了代码.该功能是在创建新用户时发送电子邮件.我现在丢失了代码.我们可以从firebase中提取代码吗?

node.js firebase google-cloud-functions firebase-console

22
推荐指数
1
解决办法
7297
查看次数

具有Google云功能的Google Cloud端点

我无法找到有关如何将GCF与Google Cloud Endpoints连接的文档.据我所知,可以将Google Cloud Endpoints配置为访问内部云资源.目前尚不清楚如何将负载均衡器与端点服务一起使用.

使用Cloud Datastore构建可伸缩Web应用程序文章中,它表明您应该能够配置从云端点到云功能的直接连接.没有迹象表明您需要在它们之间安装任何计算引擎或其他基础设施.是否有关于如何将云端点连接到云功能的文档或教程?有人设法连接这两项服务吗?

google-cloud-endpoints google-cloud-datastore google-cloud-platform google-cloud-functions

22
推荐指数
1
解决办法
4012
查看次数

Firebase云功能:如何处理连续请求

在使用Firebase(在这种情况下使用Firebase云功能)时,我们必须为每个带宽字节付费.

所以,我想知道我们如何才能处理某个人以某种方式找到我们的端点然后故意(通过脚本或工具)连续请求的情况?

我在互联网上做了一些搜索,但没有看到任何可以帮助.除了这个,但没有真正有用.

firebase google-cloud-functions

22
推荐指数
2
解决办法
2295
查看次数

如何通过firebase函数将数据写入firestore?

我可以很容易地找到如何为firestore事件添加触发器,但是我找不到有关如何使用firebase函数写入firestore的任何文档.

例如,我有以下内容:

export const listener = functions.auth.user().onCreate((x)=>{
    //firestore function to add an entry for user with fields...
})
Run Code Online (Sandbox Code Playgroud)

似乎没有办法做到这一点?将数据添加到firestore的逻辑应该写在客户端吗?如果是这样意味着我不需要为每个平台重写该功能?

firebase typescript google-cloud-functions google-cloud-firestore

22
推荐指数
1
解决办法
9777
查看次数

无法看到部署的Firebase功能

我按照以下步骤操作:

  1. Firebase CLI(命令行界面)需要Node.js和npm,您可以按照https://nodejs.org/上的说明进行安装.

    • 安装Node.js也会安装npm
  2. 安装Node.js和npm后,通过npm安装Firebase CLI:
    npm install -g firebase-tools

    • 这将安装全局可用的firebase命令.要更新到最新版本,请重新运行相同的命令
  3. 初始化您的项目:
    a.运行firebase登录以通过浏览器登录并验证firebase工具.

    b.转到Firebase项目目录或创建目录

    C.运行firebase init函数

    • 该工具为您提供了使用npm安装依赖项的选项.如果要以其他方式管理依赖项,则可以安全地拒绝.
  4. 选择关联的firebase项目

  5. 选择Y以使用npm安装依赖项

  6. 转到目录设置firebase功能

  7. 使用您创建的函数编辑index.js文件

  8. 运行firebase使用--add添加Firebase项目

  9. 运行firebase deploy --only函数来部署该功能

完成所有这些后,我在部署完成后在终端中收到消息但在Firebase控制台中,当我单击"功能"选项卡时,没有列出任何功能!?

firebase google-cloud-functions firebase-console

21
推荐指数
4
解决办法
1万
查看次数

Firebase云功能部署错误

不规则地我的firebase部署卡在此日志中:

i  functions: updating function [FUNCTION NAME]...
Run Code Online (Sandbox Code Playgroud)

取消部署并重试后,它会抛出以下错误消息:

?  functions: failed to update function resetBadgeCount
?  functions: HTTP Error: 400, An operation on function [FUNCTION NAME] 
in region us-central1 in project [PROJECT NAME] is already in progress. 
Please try again later.
Run Code Online (Sandbox Code Playgroud)

所以它的接缝就像部署卡住并保持在管道阻塞进一步部署.过了一会儿,让我再次正常部署这些功能.但这有解释吗?或者甚至可以说一句话?

firebase google-cloud-functions

21
推荐指数
3
解决办法
1万
查看次数

Firebase的云功能 - 获取当前用户ID

花了一段时间寻找一个似乎是一个简单问题的解决方案,但是......如何在云功能中获取当前用户的详细信息(何时不使用functions.auth触发器)?我相信必须有一个简单的解决方案.(我希望)

感谢您的回复...刚刚完成了但是如何在存储触发事件中从Firebase数据库中获取/ user/uid?例如

exports.addUploadInfoToDatabase = functions.storage.object().onChange(event => {
  console.log("firebase storage has been changed");
  // need to find the uid in here somehow
  admin.database().ref(`/user/uid`).push({testKey:"testData"});
})
Run Code Online (Sandbox Code Playgroud)

如果我错过了你的回复中的重点,那就是Applogies.

谢谢...

firebase google-cloud-functions

21
推荐指数
1
解决办法
1万
查看次数

Google云端功能是否受到DDoS攻击保护?

据我了解,我的Google云功能可以全球访问.如果我想控制对它们的访问,我需要将授权作为函数本身的一部分来实现.说,我可以使用基于承载令牌的方法.这将保护此功能背后的资源免受未经授权的访问.

但是,由于该功能在全球范围内可用,它仍然可以由坏人进行DDoS编辑.如果攻击不如谷歌的防御强,我的功能/服务可能仍然是响应.这很好.但是,我不想支付我未授权访问该功能的一方所做的功能调用.(因为计费是每个函数调用的数量).这就是为什么在我负责收费之前了解Google云端功能是否检测到DDoS攻击以及启用反措施对我来说非常重要.

security google-cloud-platform google-cloud-functions

21
推荐指数
4
解决办法
3586
查看次数

Firebase部署错误从非零退出代码开始(项目路径中的空间)

我最近遇到firebase deploy命令的问题.在firebase部署命令之后,除了firebase(存储,数据库等)之外,所有其他人都被部署了所以我决定重新安装firebase来修复这种情况,但重新安装后我的问题变大了.现在没有部署它们,并出现以下错误:

i deploying database, functions
Running command: npm --prefix $RESOURCE_DIR run lint
npm ERR! path C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\faruk\AppData\Roaming\npm-cache\_logs\2018-01-24T18_21_34_878Z-debug.log

Error: functions predeploy error: Command …
Run Code Online (Sandbox Code Playgroud)

node.js firebase google-cloud-functions firebase-cli

21
推荐指数
4
解决办法
1万
查看次数

传入的JSON对象不包含client_email字段

我正在尝试创建一个Firebase云功能。因此,我将在本地运行我的Firebase云功能。但是,如何设置身份验证无效。

我已经安装了Firebase工具:https ://firebase.google.com/docs/functions/local-emulator 我已经运行了命令firebase login,所以现在我已登录。然后,通过本教程创建了json密钥:https : //cloud.google.com/docs/authentication/getting-started 现在,如果我输入echo $GOOGLE_APPLICATION_CREDENTIALS结果,则/home/$USER/.google/****.json包含

"project_id","private_key_id","private_key","client_email", "client_id",  "auth_uri", "token_uri", "auth_provider_x509_cert_url", "client_x509_cert_url"
Run Code Online (Sandbox Code Playgroud)

我也尝试安装完整的google cloud sdk并运行:gcloud auth application-default login但是没有成功。

Npm软件包版本:

"firebase-functions":"3.0.2"
"firebase-admin": "8.2.0"
Run Code Online (Sandbox Code Playgroud)

我想我已经提供了足够的信息,但是如果您愿意,可以随时问我更多。

const functions = require("firebase-functions");
const admin = require("firebase-admin");
const express = require("express");
const app = express();
app.get("/", async (req, res) => {
admin.firestore().collection('something').get().then((collection) =>
    return res.send({"count": collection.docs.length, "status": 200});
});
exports.exports = functions.https.onRequest(app);
Run Code Online (Sandbox Code Playgroud)

代码并不重要,最重要的是,即使我已经完成了所有这些步骤,当我在本地模拟Firebase firebase serve并触发函数时,却出现此错误:错误:传入的JSON对象不包含client_email领域

我可以确保您的json文件包含client_email字段。

您可以帮我与Google进行身份验证吗?

谢谢你的帮助。

javascript firebase google-cloud-functions firebase-admin google-auth-library

21
推荐指数
3
解决办法
2717
查看次数