Search code examples
google-cloud-platformgoogle-cloud-storage

Google Cloud Functions: missing main.py


When trying to deploy a Python project to Google Cloud functions using the command

gcloud functions deploy my_function --entry-point reply --runtime python38 --trigger-http --allow-unauthenticated

I get

Deploying function (may take a while - up to 2 minutes)...⠛
For Cloud Build Stackdriver Logs, visit: https://[...] Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: missing main.py and GOOGLE_FUNCTION_SOURCE not specified. Either create the function in main.py or specify GOOGLE_FUNCTION_SOURCE to point to the file that contains the function; Error ID: 5c04ec9c

But I do have a main.py file in the folder.

I checked the platform and the file main.py is not being uploaded, while the files inside folders are.


Solution

  • The solution was to omit this line from .gcloudignore:

    #!include:.gitignore
    

    I don't really understand why.

    My .gitignore is:

    .*
    *.json