【问题标题】:How to change the deployment region of a google cloud function?如何更改谷歌云功能的部署区域?
【发布时间】:2021-08-18 15:13:00
【问题描述】:

我正在使用谷歌 SDK 创建一个谷歌云功能...当我使用以下命令进行部署时会出现问题:

gcloud functions deploy my-first-function --entry-point HelloWorld.Function --runtime dotnet3 --trigger-http --allow-unauthenticated

问题是,执行上述命令后,函数区域是这样的:

该区域为 us-central1。如何更改此区域?

【问题讨论】:

  • 尝试将--region asia-east1(您想要的任何区域)添加到命令中?只要确保this list 中提到了该地区

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


【解决方案1】:

正如 Dharmaraj 所提到的,有一个参数可以指定您要在其中部署函数的区域。将函数部署在区域 us-central1 的原因很可能是因为您的 gcloud sdk 默认为该区域。

通过添加以下参数来运行您的命令:

gcloud functions deploy my-first-function --region=<my_region> --entry-point HelloWorld.Function --runtime dotnet3 --trigger-http --allow-unauthenticated

更改为 regions listed here. 之一

参考:https://cloud.google.com/sdk/gcloud/reference/functions/deploy#--region

【讨论】:

    【解决方案2】:

    在不同地域部署同一个函数,同名,前面放一个负载均衡器是很常见的。像这样,请求在距离请求者最近的区域中提供服务。

    您可以在您想要的区域部署功能,您不会支付更多费用,它是无服务器的,您只需在使用时付费。但是,有些地区比其他地区更贵,请小心。

    正如CaioT所说,使用--region参数来指定它。

    您也可以像这样在 gcloud SDK 中设置默认区域

    gcloud config set functions/region <REGION>
    

    【讨论】:

      猜你喜欢
      • 2019-01-30
      • 2017-08-15
      • 2021-02-26
      • 2018-09-14
      • 1970-01-01
      • 2020-05-21
      • 1970-01-01
      • 2019-08-30
      • 2022-09-23
      相关资源
      最近更新 更多