简体   繁体   English

“错误:(gcloud.functions.call)ResponseError:状态= [404],代码= [确定],消息= [项目ABC中us-central1区域中的函数XYZ不存在]”

[英]"ERROR: (gcloud.functions.call) ResponseError: status=[404], code=[Ok], message=[Function XYZ in region us-central1 in project ABC does not exist]"

I am testing a cloud function.我正在测试云 function。

When I run it from the "Testing" tab, online, and I paste the json dictionary as the argument to be passed as the request variable of the cloud function in the "Triggering event" editor as:当我从“测试”选项卡在线运行它时,我将 json 字典作为参数粘贴到“触发事件”编辑器中作为云 function 的请求变量传递为:

{"api_key":"MY_API_KEY"}

(with MY_API_KEY to be replaced with a plain text key) then the function runs through. (将 MY_API_KEY 替换为纯文本密钥)然后 function 运行。

From bash, using gcloud instead, the same function fails with:从 bash 开始,使用gcloud代替,相同的 function 失败:

gcloud functions call MY_CLOUD_FUNCTION --data '{"api_key":"$API_KEY"}'
 gcloud functions call MY_CLOUD_FUNCTION --data '{"api_key":"$API_KEY"}' ERROR: (gcloud.functions.call) ResponseError: status=[404], code=[Ok], message=[Function MY_CLOUD_FUNCTION in region us-central1 in project MY_CLOUD_PROJECT does not exist]

And this is most likely not a problem of the triggering event which just happens to be part of the args but should not play a role here.这很可能不是触发事件的问题,它恰好是 args 的一部分,但不应该在这里发挥作用。 It is a problem of the different regions.这是不同地区的问题。 gcloud expects the default region us-central1 while my function is europe-west3 (from the "Details" tab). gcloud需要默认区域us-central1而我的 function 是europe-west3 (来自“详细信息”选项卡)。

How can I tell gcloud to use the region of the function, and not the default region?如何告诉gcloud使用 function 的区域,而不是默认区域? Or what would be another way to fix this?或者还有什么方法可以解决这个问题?

gcloud assumes defaults (that may be get|set using gcloud config ) gcloud假定默认值(可以使用gcloud config获取|设置)

In this case, you should add the flag --region=europe-west3 to your command to specify the intended region, ie:在这种情况下,您应该在命令中添加标志--region=europe-west3以指定预期区域,即:

REGION="europe-west3"

gcloud functions call your-function \
--region=${REGION} \
--data="{\"api_key\":\"${API_KEY}\"}"

You can verify this behavior (hopefully) by:您可以通过以下方式验证此行为(希望如此):

gcloud config list
[core]
account = your@email.com

Your active configuration is: [default]

NOTE The above command does not include functions/region ;注意上述命令不包括functions/region I suspect this is because us-central1 is the default (.) default value.我怀疑这是因为us-central1是默认 (.) 默认值。

gcloud config get-value functions/region
us-central1

I discourage storing global state in gcloud config (partly because it results in this type of confusion) but, you may also:我不鼓励将全局 state 存储在gcloud config中(部分原因是它会导致这种类型的混淆)但是,您也可以:

gcloud config set functions/region europe-west3
Updated property [functions/region].

gcloud config get-value functions/region
europe-west3

gcloud functions call your-function \
--data="{\"api_key\":\"${API_KEY}\"}"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 us-central1 以外的区域用于 Google Cloud Functions - use region other than us-central1 for Google Cloud Functions 错误: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden] - ERROR: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden] 部署云时出错 function 错误: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden] - Error deploying a cloud function ERROR: (gcloud.functions.deploy) ResponseError: status=[403], code=[Forbidden] GCloud无服务器VPC连接器是否可在我们 - central1之外使用? - Is GCloud Serverless VPC connector available outside us-central1? 启动虚拟机实例“ instance-1”失败。 错误:配额超过“ CPUS”。 限制:us-central1地区为72.0 - Starting VM instance 'instance-1' failed. Error: Quota 'CPUS' exceeded. Limit: 72.0 in region us-central1 Function us-central1 的调用配额限制......已弃用? - Function invocation quota limits for us-central1… deprecated? 错误:(gcloud.functions.deploy)消息=构建失败:function.js 不存在 - ERROR: (gcloud.functions.deploy) message=Build failed: function.js does not exist (gcloud.container.clusters.create)ResponseError:代码= 400,消息=用户无权访问服务帐户“默认” - (gcloud.container.clusters.create) ResponseError: code=400, message=The user does not have access to service account “default” 无法在 us-central1 中更新加密密钥 - Can't update cryptokey in us-central1 'projects / $ project_id / regions / us-central1所需的'compute.regions.get'权限 - Required 'compute.regions.get' permission for 'projects/$project_id/regions/us-central1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM