执行gcloud functions describe返回404但函数已正确部署
解决gcloud functions describe 404错误(函数已部署且控制台可见)
问题场景
已部署2nd gen云函数screenwriter,通过gcloud functions list可看到函数处于ACTIVE状态,gcloud配置的区域、项目均与函数一致,但执行gcloud functions describe screenwriter时抛出404错误,提示函数不存在。
命令执行结果:
# gcloud functions list NAME STATE TRIGGER REGION ENVIRONMENT screenwriter ACTIVE HTTP Trigger us-central1 2nd gen # gcloud functions describe screenwriter ERROR: (gcloud.functions.describe) ResponseError: status=[404], code=[Ok], message=[Function screenwriter in region us-central1 in project personal-xyz does not exist] # gcloud config list [compute] region = us-central1 [core] account = mypersonal@email.com project = personal-xyz
解决方案
1. 指定函数的生成版本(关键)
gcloud functions命令默认针对1st gen函数,你的函数是2nd gen,必须添加--gen2参数才能正确查询:
gcloud functions describe screenwriter --gen2
2. 强制指定区域和项目参数(排除配置隐性问题)
虽然配置已正确,但直接在命令中指定参数可避免本地配置的潜在冲突:
gcloud functions describe screenwriter --gen2 --region us-central1 --project personal-xyz
3. 刷新gcloud组件与缓存
如果本地缓存导致信息不一致,先更新gcloud组件并重新确认2nd gen函数列表:
gcloud components update # 确认2nd gen函数列表 gcloud functions list --gen2 # 再次执行describe命令 gcloud functions describe screenwriter --gen2
内容的提问来源于stack exchange,提问作者varno
相关产品推荐
相关产品推荐

