【问题标题】:Issue while deploy the cloud function部署云功能时的问题
【发布时间】:2020-08-06 11:25:39
【问题描述】:

我是 GCP 的新手。我创建了一个云功能并尝试部署它。我在部署时遇到以下错误。谁能帮我解决这个问题?谢谢!

Command: 
gcloud functions deploy first_cloud_function_http --runtime python37 --trigger-http --allow-unauthenticated --verbosity debug

Error Logs:
DEBUG: Running [gcloud.functions.deploy] with arguments: [--allow-unauthenticated: "True", --runtime: "python37", --trigger-http: "True", --verbosity: "debug", NAME: "first_cloud_function_http"]
INFO: Not using ignore file.
INFO: Not using ignore file.
Deploying function (may take a while - up to 2 minutes)...failed.                                                                            
DEBUG: (gcloud.functions.deploy) OperationError: code=13, message=Failed to initialize region (action ID: 78ed38913711b6cd)
Traceback (most recent call last):
  File "/home/hasher/GN/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 983, in Execute
    resources = calliope_command.Run(cli=self, args=args)
  File "/home/hasher/GN/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 808, in Run
    resources = command_instance.Run(args)
  File "/home/hasher/GN/google-cloud-sdk/lib/surface/functions/deploy.py", line 351, in Run
    return _Run(args, track=self.ReleaseTrack())
  File "/home/hasher/GN/google-cloud-sdk/lib/surface/functions/deploy.py", line 305, in _Run
    on_every_poll=[TryToLogStackdriverURL])
  File "/home/hasher/GN/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 318, in CatchHTTPErrorRaiseHTTPExceptionFn
    return func(*args, **kwargs)
  File "/home/hasher/GN/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 369, in WaitForFunctionUpdateOperation
    on_every_poll=on_every_poll)
  File "/home/hasher/GN/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 151, in Wait
    on_every_poll)
  File "/home/hasher/GN/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 121, in _WaitForOperation
    sleep_ms=SLEEP_MS)
  File "/home/hasher/GN/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 219, in RetryOnResult
    result = func(*args, **kwargs)
  File "/home/hasher/GN/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 73, in _GetOperationStatus
    raise exceptions.FunctionsError(OperationErrorToString(op.error))
googlecloudsdk.api_lib.functions.exceptions.FunctionsError: OperationError: code=13, message=Failed to initialize region (action ID: 78ed38913711b6cd)
ERROR: (gcloud.functions.deploy) OperationError: code=13, message=Failed to initialize region (action ID: 78ed38913711b6cd)

【问题讨论】:

  • 您没有在命令中指定区域。
  • 这听起来像是一个好的答案@Johan 的开始,特别是如果您可以包含一个如何将区域传递到调用中的示例。 :)
  • 谢谢弗兰克。在我写评论的那段时间里,我无法详细说明,但想为其他渴望接球的人提供一个正确的方向:)

标签: python google-cloud-platform google-cloud-functions


【解决方案1】:

请注意,如gcloud functions deploy 命令的文档中所述,您必须设置--region 标志。

要查看 Cloud Functions 可用的可用区域,请参阅以下sections of the documentation

例如,如果您想在europe-west1 区域部署函数,运行以下命令就足够了:

gcloud functions deploy first_cloud_function_http --region europe-west1 --runtime python37 --trigger-http --allow-unauthenticated --verbosity debug

此外,如果您想避免使用 --region 标志,您可以通过运行 set a default region 用于 Cloud Functions:

gcloud config set functions/region REGION

您可以将REGION 字段更改为locations mentioned above 中的任何一个。

【讨论】:

    猜你喜欢
    • 2019-10-09
    • 1970-01-01
    • 2019-06-26
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    • 2018-12-29
    • 2020-10-19
    • 2020-11-02
    相关资源
    最近更新 更多