firebase - 使用 vpcConnector 部署 firebase 功能

标签 firebase google-cloud-functions firebase-cli

最新版本的 firebase ( https://github.com/firebase/firebase-functions/releases/tag/v3.11.0 ) 允许我们为要使用的函数指定 VPC 连接器。

export const redis = functions.runWith({
  vpcConnector: 'my-redis-connector',
  vpcConnectorEgressSettings: 'PRIVATE_RANGES_ONLY'
}).https.onRequest((req, res) => {
  const client = redisLib.createClient(REDIS_PORT, REDIS_HOST)
  
  if (client.connected === true) {
    return res.status(200).send({redis: 'found'});
  } else {
    return res.status(404).send({ redis: 'not found'});
  }
})

使用 firebase 工具 CLI firebase deploy --only function:redis 部署该函数后,我没有看到正在创建的 vpc 连接器:gcp-function-after-deployment

除了使用使用 vpcConnector 的 gcloud 之外,还有其他方法来部署 firebase 功能吗?

最佳答案

使用此新功能部署 Firebase Function 不会创建 VPC 连接器,它仅允许您通过向函数本身添加新配置来使用 GCP 中现有的 VPC 连接器。

因此,为了使其正常工作,您需要首先使用 this documentation 中演示的说明在 GCP 中创建 VPC 连接器.

关于firebase - 使用 vpcConnector 部署 firebase 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63996944/

相关文章:

firebase - 如何禁用 Firebase 存储模拟器?

javascript - 监听子列表的变化

android - java.lang.RuntimeException : Unable to instantiate application. ClassNotFoundException:找不到类

firebase - 以相同文本开头的多个集合的云函数触发器

google-cloud-firestore - 文档父名称缺少正斜杠

android - 在 Firebase 中添加应用程序时的 Flutter 选项是单独添加 IOS 和 Android 的替代方案

java - Firebase 仍在一对一聊天应用程序中创建两个房间

android - 由于 GRPC 和 R8,Firestore (0.6.6-dev) 出现内部错误

google-cloud-platform - 有没有办法逐步部署 Cloud Functions 并在出现问题时自动回滚?

node.js - 云函数: Promises must be handled appropriately