使用europe-west1时,Google Cloud功能部署错误

问题描述 投票:0回答:2

我正在使用云函数来部署python函数(版本= 3.7,内存= 1go和超时= 1s)。

到目前为止,它完美无缺。

但是,我注意到,默认情况下,云功能的区域设置为us-central1。我需要我的功能在europe-west1所以我改变了区域(https://cloud.google.com/functions/docs/locations)使用

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

我不明白为什么它适用于我们 - central1而不是europe-west1。

有任何想法吗 ?

谢谢你的帮助!

编辑:

Thx Renaud和Pablo

错字在我的信息中,但我认为我得到了正确的命令。这里是 :

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

我仍然得到相同的错误消息。

但是这个

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

工作良好。

希望有人有个主意:)谢谢!

python deployment google-cloud-functions region
2个回答
0
投票

更新后更新(和PabloAlmécijaRodríguez的回答):

您必须遵循此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 …]

所以你应该这样做:

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

0
投票

您有一些拼写错误(以及两个缺少的参数,以防它是您第一次部署云功能)。您的命令应如下所示:

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

最后的参数是触发器和运行时的一个示例(在这种情况下,您使用的非常相同),因为如果它是第一次部署该函数,则需要指定所需的触发器,理想情况下也需要指定运行时。

正如Renaud所提到的,这里是关于部署云功能的参数的documentation

© www.soinside.com 2019 - 2024. All rights reserved.