OperationError deploying gcloud function publish

Posted

技术标签:

【中文标题】OperationError deploying gcloud function publish【英文标题】: 【发布时间】:2020-03-14 10:24:55 【问题描述】:

我正在尝试对Google Cloud Pub/Sub Triggers 进行介绍。运行示例代码时:

gcloud functions deploy publish --runtime nodejs8 --trigger-http

我收到以下错误:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Node.js module defined by file index.js is expected to export function named publish

stackdriver 上的日志显示:

D 2019-11-18T23:53:41.689Z publish Node.js module defined by file index.js is expected to export function named publish  
E 2019-11-18T23:53:41.761Z Cloud Functions CreateFunction us-central1:publish <email> INVALID_ARGUMENT Cloud Functions CreateFunction us-central1:publish <email> 
E 2019-11-18T23:54:15.667Z Cloud Functions UpdateFunction us-central1:publish <email> FAILED_PRECONDITION Cloud Functions UpdateFunction us-central1:publish <email> 

【问题讨论】:

【参考方案1】:

原来我试图从错误的目录进行部署。正确的 index.js 文件包含函数定义,并允许成功部署函数。

【讨论】:

以上是关于OperationError deploying gcloud function publish的主要内容,如果未能解决你的问题,请参考以下文章

gcloud函数:如何在部署期间包含本地javascript助手文件?

15-Kubernetes-Pod控制器详解-Deployment(Deploy)

glReadPixels() 设置 GL_INVALID_OPERATION 错误

K8SRCRS和Deployment

k8s-deployment

再战 k8s:deployment