3
votes

I am using cloud function to deploy a python function (version=3.7, memory=1go and timeout=1s).

So far, it perfectly works.

However, I've noticed that, by default, the cloud function has its region set to us-central1. I need my function to be in europe-west1 so I've change the region (https://cloud.google.com/functions/docs/locations) using

gcloud function deploy .... --region europe-west1

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Error: function load attempt timed out

I don't understand why it works with us-central1 and not europe-west1.

Any ideas ?

Thx for your help !

EDIT :

Thx Renaud and Pablo

Typos were in my message, but I think I got the right command. Here it is :

gcloud functions deploy my_test --entry-point my_test_1 --runtime python37 --memory 1024MB --region=europe-west1 --trigger-http

And I still got the same error message.

But this

gcloud functions deploy my_test --entry-point my_test_1 --runtime python37 --memory 1024MB --trigger-http

works fine.

Hope someone has an idea :) Thank you !

2
See the update to my answer: You have to follow the doc I mentioned in my answer and add = when it is needed, as detailed in the doc.Renaud Tarnec

2 Answers

3
votes

Updated following your update (and Pablo Almécija Rodríguez's answer):

You have to follow this doc (i.e. the "complete reference for the deploy command") and add = when it is needed, as detailed in the doc:

gcloud functions deploy (NAME : --region=REGION) [--entry- point=ENTRY_POINT] [--memory=MEMORY] [--retry]
[--runtime=RUNTIME] [--service-account=SERVICE_ACCOUNT]
[--source=SOURCE] [--stage-bucket=STAGE_BUCKET] [--timeout=TIMEOUT]
[--update-labels=[KEY=VALUE,…]] [--clear-env-vars     |
--env-vars-file=FILE_PATH     | --set-env-vars=[KEY=VALUE,…]     | --remove-env-vars=[KEY,…] --update-env-vars=[KEY=VALUE,…]] [--clear-labels     | --remove-labels=[KEY,…]]
[--trigger-bucket=TRIGGER_BUCKET     | --trigger-http     |
--trigger-topic=TRIGGER_TOPIC     | --trigger-event=EVENT_TYPE --trigger-resource=RESOURCE] [GCLOUD_WIDE_FLAG …]

So you should do:

gcloud functions deploy my_test --entry-point=my_test_1 --runtime=python37 --memory=1024MB --timeout=1s --region=europe-west1 --trigger-http
0
votes

You have a couple of typos (and two missing parameters in case it is the first time you deploy the Cloud Function). Your command should look like this:

gcloud functions deploy ... --region=europe-west1 [--trigger-http --runtime=python37]
               ^                    ^

Last parameters were an example of trigger and runtime (in this case you use that very same), since if it is the first time you deploy the function, you need to specify your desired trigger and ideally the runtime too.

As Renaud mentioned, here is the documentation on the parameters to deploy Cloud Functions.