如何更改 google 云函数的部署区域?

How to change the deployment region of a google cloud function?

我正在使用 google SDK 创建一个 google 云函数...当我使用以下命令部署时出现问题:

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

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

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

正如 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

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

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

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

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

gcloud config set functions/region <REGION>