我有一个新项目,但希望测试预定的功能。我错过了什么吗?
$ firebase deploy
=== Deploying to 'testing-db'...
i deploying functions
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
! functions: missing required API cloudbuild.googleapis.com. Enabling now...
+ functions: required API cloudfunctions.googleapis.com is enabled
+ functions: required API cloudbuild.googleapis.com is enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (24.45 KB) for uploading
i functions: ensuring required API pubsub.googleapis.com is enabled...
i functions: ensuring required API cloudscheduler.googleapis.com is enabled...
! functions: missing required API cloudscheduler.googleapis.com. Enabling now...
+ functions: required API pubsub.googleapis.com is enabled
+ functions: required API cloudscheduler.googleapis.com is enabled
+ functions: functions folder uploaded successfully
i functions: creating Node.js 14 function scheduledFunction(us-central1)...
Functions deploy had errors with the following functions:
scheduledFunction(us-central1)
i functions: cleaning up build files...
Error: There was an error deploying functions
Index.js const functions = require('firebase-functions');
exports.scheduledFunction = functions.pubsub
.schedule('every 1 minutes')
.onRun((context) => {
return console.log('This will be run every 1 minutes!');
});
Firebase 日志显示:Error: Failed to upsert schedule function scheduledFunction in region europe-west1
最佳答案
当您在 Firebase Functions 中使用计划函数时,会创建 Cloud Scheduler 工作所需的 App Engine 实例。你可以阅读它here .它们使用默认设置的资源位置。我认为您收到该错误是因为您指定的默认 GCP 资源位置与您计划的云功能区域之间存在差异。如果您点击 Firebase 中项目概览旁边的齿轮,您可以看到您的资源所在的位置。
检查您的 Cloud Scheduler 功能详细信息并查看它已部署到哪个区域。默认情况下,函数在 us-central1 区域中运行。检查这个 link看看我们如何改变函数的区域。
关于firebase - 谷歌预定函数 : There was an error deploying functions?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69945493/