【问题标题】:Will Firebase replace all my cloud functions?Firebase 会取代我所有的云功能吗?
【发布时间】:2021-09-04 14:22:03
【问题描述】:

在我们的组织中,我们有一个适用于所有云功能的存储库。它们都在 Python 中。我们不得不创建另一个云函数,我们决定用 NodeJS 编写它。

这个新的云功能在一个新的 repo 中,在一个新的项目中。旧功能和新功能之间没有关系。

我读到如果我使用firebase deploy --only functions,它将部署index.js 文件中的所有功能,但我不确定它是否会删除其他功能,因为我的index.js 中没有任何内容关于其他用 Python 编写的云函数的文件。

使用firebase deploy --only functions 部署我的新功能是否安全?我不想替换其他功能,只需添加我的新功能即可。

谢谢!

【问题讨论】:

    标签: firebase google-cloud-functions firebase-cli


    【解决方案1】:

    如果您运行 firebase deploy 或 firebase deploy --only 函数,Firebase 可能会替换项目中的所有 Cloud Functions。

    如果您只想部署单个函数或一组函数,您可以将其指定为附加参数:

    firebase deploy --only functions:yourNewFunction
    

    另请参阅 deploying specific functions 上的 Firebase 文档。

    【讨论】:

    • 谢谢!这种方法的唯一问题是我必须将所有功能设置为部署命令
    • 您可以在一次调用中提供多个函数,例如--only functions:yourNewFunction,functions:yourOtherNewFunctionl。如果您经常部署同一组函数,则可以将这些函数组合在 exports 中,并使用单个 --only functions:yourGroup 部署它们。两者的示例都显示在我链接的文档中。
    【解决方案2】:

    我刚刚对此进行了测试,每当使用 firebase deployfirebase deploy --only functions 部署函数时,index.js 找不到函数名称时会显示此消息:

    The following functions are found in your project but do not exist in your local source code:
            <function_name>(<region>)
    
    If you are renaming a function or changing its region, it is recommended that you create the new function first before deleting the old one to prevent event loss. For more info, visit https://firebase.google.com/docs/functions/manage-functions#modify
    

    如果某个函数与已部署的其中一个云函数同名,它将替换旧函数。但是,如果它有不同的名称,则不应替换它,您应该是安全的。如果您仍然不确定,请随时使用快速启动功能进行测试。

    【讨论】:

      猜你喜欢
      • 2018-05-26
      • 2019-11-18
      • 1970-01-01
      • 1970-01-01
      • 2020-06-28
      • 2021-01-12
      • 2020-06-09
      • 2017-10-28
      • 2018-11-29
      相关资源
      最近更新 更多