如何从index.ts分别导出firebase cloud函数2GEN?
我正在尝试通过以下此文档将特定的云功能更新为第二代: https:https:// https:// firebase .google.com/docs/functions/beta 它说
“支持使用functions.config()的环境配置的支持 已从Firebase V2的云功能中删除。 functions.config() 被环境变量替换。”
函数,我必须为v1函数运行functions.config()。
export { my1GenFunction} from "./my_first_gen_function";
export { my2GenFunction} from "./my_second_gen_function";
admin.initializeApp(functions.config().firebase);
...
但是,当我尝试用<<<代码> functions.config(),我正在得到云运行错误
用户提供的容器无法在端口上启动和侦听 由端口= 8080环境变量定义。为此记录 修订可能包含更多信息。
检查修订日志告诉我:
错误:functions.config()在云功能中不再可用 对于firebase v2。请参阅最新文档以获取信息 关于如何过渡到使用环境变量
是否可以将这些出口分开?
谢谢!
I am trying to update a specific cloud function to 2nd gen by following this documentation : https://firebase.google.com/docs/functions/beta
and it says
"Support for Environment Configuration with functions.config() has
been removed from Cloud Functions for Firebase v2. functions.config()
is replaced by environment variables."
The problem is, that my index.ts file exports v1 and v2 functions and I have to run functions.config() for the v1 functions.
export { my1GenFunction} from "./my_first_gen_function";
export { my2GenFunction} from "./my_second_gen_function";
admin.initializeApp(functions.config().firebase);
...
However, when I try to deploy the v2 function with the functions.config()
, I am getting a Cloud Run Error
The user-provided container failed to start and listen on the port
defined provided by the PORT=8080 environment variable. Logs for this
revision might contain more information.
Checking the revision log tells me:
Error: functions.config() is no longer available in Cloud Functions
for Firebase v2. Please see the latest documentation for information
on how to transition to using environment variables
Is there a way to split those exports?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的代码中,您可能没有收听传入的HTTP请求,您是否有端口80的ENV变量?这样的事情:
In your code probably you aren't listening to incoming HTTP requests, do you have an env variable for the port 80? something like this: