serverless deploy -c serverless_stage.yml Serverless: Packag-6ren">
gpt4 book ai didi

google-cloud-platform - 如何解决错误 : "Deployment failed: RESOURCE_ERROR" (The GCF v1beta2 API is deprecated) when deploying serverless GCP?

转载 作者:行者123 更新时间:2023-12-05 00:45:53 25 4
gpt4 key购买 nike

不知道为什么,但无服务器 GCP 的成功部署因错误而停止工作:

team27> serverless deploy -c serverless_stage.yml
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Compiling function "user"...
Serverless: Compiling function "volunteer"...
Serverless: Compiling function "clear"...
Serverless: Uploading artifacts...
Serverless: Artifacts successfully uploaded...
Serverless: Updating deployment...
Serverless: Checking deployment update progress...
..
Error --------------------------------------------------

Error: Deployment failed: RESOURCE_ERROR

{"ResourceType":"cloudfunctions.v1beta2.function","ResourceErrorCode":"403","ResourceErrorMessage":{"code":403,"message":"The GCF v1beta2 API is deprecated. See https://cloud.google.com/functions/docs/migrating","status":"PERMISSION_DENIED","details":[],"statusMessage":"Forbidden","requestPath":"https://cloudfunctions.googleapis.com/v1beta2/projects/stageteam27/locations/us-central1/functions","httpMethod":"POST"}}
at throwErrorIfDeploymentFails (xxx\team27\node_modules\serverless-google-cloudfunctions\shared\monitorDeployment.js:71:11)
at xxx\team27\node_modules\serverless-google-cloudfunctions\shared\monitorDeployment.js:42:17
at processTicksAndRejections (internal/process/task_queues.js:93:5)

For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com

Your Environment Information ---------------------------
Operating System: win32
Node Version: 12.13.1
Framework Version: 1.64.0
Plugin Version: 3.4.0
SDK Version: 2.3.0
Components Core Version: 1.1.2
Components CLI Version: 1.4.0

正如 https://cloud.google.com/functions/docs/migrating 中的建议我执行了 gcloud 组件更新同样的错误...

这是我的 yml:

service: stageteam27

provider:
name: google
stage: stage
runtime: nodejs10
region: us-central1
project: stageteam27
credentials: /xxx/stageteam27keyfile.json
environment:
IS_PROD: 'false'

plugins:
- serverless-google-cloudfunctions

package:
exclude:
- node_modules/**
- .gitignore
- .git/**

functions:
user:
handler: userMessage
events:
- http: user

volunteer:
handler: volunteerMessage
events:
- http: volunteer

clear:
handler: clearCommand
events:
- http: clear

最佳答案

如果您使用无服务器框架在 GCP 中部署云功能,以下引用资料可能会对您有所帮助,

https://github.com/serverless/serverless-google-cloudfunctions/blob/HEAD/MIGRATION_GUIDE.md


选项 2

第二个是从开发者的角度来看,也就是说你需要对serverless.yml做一些修改。

1. Change the service name or change the function name to make sure this function is different from the older one.

2. Redeploy the functions.

3. Once it's done,you may consider delete the old ones.

除了将 serverless 库和 serverless-google-cloudfunctions 插件升级到最新版本之外,您可以尝试将服务重命名为 以外的其他名称stageteam27(例如 stageteam27-v2stageteam27-newstage-team-27)。

就我而言,仅重命名函数并不能解决部署问题,而服务名称仍然是旧名称。

请注意,函数名称现在将具有以下模式${serviceName}-${stage}-${functionName}.

编辑:

如果我们不想有这么长的函数名,我们可以在serverless.yml中指定函数名。

例如

service: myService

provider:
name: google
stage: prod
runtime: nodejs10

functions:
myFunction:
# this will be the function name
name: myFunction
handler: myFunctionHandler

在这种情况下,部署的函数名称将仅为 myFunction。如果我们不指定名称,它将是 myService-prod-myFunction

关于google-cloud-platform - 如何解决错误 : "Deployment failed: RESOURCE_ERROR" (The GCF v1beta2 API is deprecated) when deploying serverless GCP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62657895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com