gpt4 book ai didi

firebase - 将计划函数部署到 Firebase 函数

转载 作者:行者123 更新时间:2023-12-04 04:24:22 26 4
gpt4 key购买 nike

如何将预定函数部署到 Google Firebase Functions?

我创建了一个名为的服务帐户

cron-notifications



我的函数代码
exports.notification_email = functions
.region('europe-west1')
.pubsub
.schedule('0 * * * *')
.timeZone('Europe/Stockholm')
.onRun(async (event) => { ... }

当我尝试使用
$ firebase deploy --only functions:notification_email 

我收到以下错误。

Error: HTTP Error: 400, Location must equal europe-west1 because the App Engine app that is associated with this project is located in europe-west1



我可以部署其他未安排到 "europe-west1"的功能。我认为我的项目在 europe-west1(我如何验证?)

我也尝试创建一个名为 的函数notification_email ,位于 europe-west1,直接来自 GCP Cloud Functions Web UI,然后部署我的函数 - 覆盖它 - 具有相同的结果。

我也尝试使用设置区域

gcloud config set functions/region europe-west1



documentation 中所述,结果相同。

我的 $ gclod 配置列表
[core]
account = myAccount
disable_usage_reporting = True
project = myProject
[functions]
region = europe-west1

请帮帮我! :)

最佳答案

当您在 Firebase Functions 中使用计划函数时,会创建一个 Cloud Scheduler 工作所需的 App Engine 实例。你可以阅读它here .

当这些资源启动以供调度程序工作时,它们使用默认情况下为资源设置的位置。

Cloud Functions for Firebase (scheduled functions only) — If you run scheduled functions, Cloud Scheduler requires a Google App Engine app; during its setup you're prompted to select your project's default Google Cloud Platform (GCP) resource location (if it wasn't already selected when setting up another service).



我认为您收到该错误是因为您指定的默认 GCP 资源位置与函数一之间存在差异。

更多背景:

Important: Cloud Scheduler requires that your project have a Google App Engine (GAE) app; during its setup you're prompted to select your project's default Google Cloud Platform (GCP) resource location. This location will be used for GCP services in your project that require a location setting, specifically, your default Cloud Storage bucket and your Cloud Firestore database. When setting your project's default GCP resource location, primarily consider where you want to store your data and files and, secondly, where you want to run any triggered functions for Cloud Firestore and Cloud Storage. After you set your project's default GCP resource location, you cannot change it.



Link

如果您点击 Firebase 中项目概览旁边的齿轮,您可以看到您的资源所在的位置。

希望这可以帮助。

关于firebase - 将计划函数部署到 Firebase 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58147444/

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