我目前正在使用Google Cloud Function来构建我的restful API . 但是,我发现它很慢,因为我的Google-Cloud-Function服务器位于“我们中心”,而我的服务是在亚洲 .
我尝试将我的Google项目的默认区域更改为"asia-west-1"并重新启动 Cloud 功能 - 我按照概述的步骤here但不幸的是,它是's still in 390659 . How can I change the function'的区域?
Google Cloud 功能似乎目前仅在us-central1区域提供 . 如果我去"Create function"(https://console.cloud.google.com/functions/add),Region下拉列表只有一个选项,它是us-central1 .
取自文档 - https://firebase.google.com/docs/functions/manage-functions#modify
// before const functions = require('firebase-functions'); exports.webhook = functions .https.onRequest((req, res) => { res.send("Hello"); }); // after const functions = require('firebase-functions'); exports.webhookAsia = functions .region('asia-northeast1') .https.onRequest((req, res) => { res.send("Hello"); });
Google Cloud 端平台上没有"asia-west-1"这样的区域 . 在撰写本文时,GCP provides the following regions in Asia:
asia-east1
asia-northeast1
asia-south1
asia-southeast1
但是, asia-northeast1 是目前亚洲唯一可用于Google Cloud 功能的GCP地区:
$ gcloud functions regions list NAME projects/xxxxxxxx/locations/europe-west1 projects/xxxxxxxx/locations/us-east1 projects/xxxxxxxx/locations/us-central1 projects/xxxxxxxx/locations/asia-northeast1
区域设置很容易错过 . 它实际上隐藏在名为“更多”的手风琴背后:
单击它会显示“区域”下拉列表(以及其他高级设置):
只需使用 --region 标志指定四个可用区域中的一个 .
--region
假设你有
$ tree . . └── index.js 0 directories, 1 file $ cat index.js exports.hello = (req, res) => { res.send(`Hello World!`); }
然后跑
gcloud functions deploy hello --region asia-northeast1 --trigger-http
应该将函数 hello 部署到region asia-northeast1 :
hello
3 回答
Google Cloud 功能似乎目前仅在us-central1区域提供 . 如果我去"Create function"(https://console.cloud.google.com/functions/add),Region下拉列表只有一个选项,它是us-central1 .
取自文档 - https://firebase.google.com/docs/functions/manage-functions#modify
没有“asia-west-1”这样的地区
Google Cloud 端平台上没有"asia-west-1"这样的区域 . 在撰写本文时,GCP provides the following regions in Asia:
asia-east1
asia-northeast1
asia-south1
asia-southeast1
但是,
asia-northeast1
是目前亚洲唯一可用于Google Cloud 功能的GCP地区:如何指定Google Cloud功能的区域
使用Google Cloud Console
区域设置很容易错过 . 它实际上隐藏在名为“更多”的手风琴背后:
单击它会显示“区域”下拉列表(以及其他高级设置):
使用gcloud
只需使用
--region
标志指定四个可用区域中的一个 .最小的工作示例
假设你有
然后跑
应该将函数
hello
部署到regionasia-northeast1
: