云函数文件名

cloud function file name

我正在尝试部署 Cloud Function。我已经在名为 gcpapp.py.

的文件中编写了函数

当我尝试部署此功能时,出现错误 Deployment failure: Function load error: File main.py that is expected to define function doesn't exist

我输入 appgcp.main 作为 Function to execute,其中 appgcp 是文件名,main 是函数名。

是否必须将函数所在的文件命名为main.py

是的,您必须将文件命名为 main.py。根据 documentation:

Source code structure

Your function's entrypoint must be defined in a Python source file named main.py.