以编程方式将Firestore添加到新的Firebase项目

时间:2019-10-17 14:00:09

标签: firebase google-cloud-platform google-cloud-firestore google-cloud-sdk

我目前正在尝试使创建新Firebase项目涉及的许多过程自动化。最终目标是能够运行脚本,并具有完全配置的Firebase和GCloud项目,其中所有内容都已部署并可以投入生产。

我设法创建了一个脚本,该脚本创建了一个新的Firebase和Google Cloud项目,下载了一个服务密钥,为该项目设置了默认区域,启用了我想要的API并部署了一组云功能。所有这些都是结合使用GCloud / Firebase CLI和各种GCloud API来完成的。

当我设置默认的Cloud Platform区域时,似乎为项目自动启用了Cloud Storage。

不幸的是,我目前无法通过手动输入Firebase控制台并单击“创建数据库”而无法将Firestore实际添加到新创建的Firebase项目中而受阻。

当我尝试将安全规则部署到Firestore时,出现以下错误:

HTTP Error: 400, Project '<Project-name>' is not a Cloud Firestore enabled project.

当我尝试通过admin SDK与firebase交互时,出现以下错误:

Error: 9 FAILED_PRECONDITION: The Cloud Firestore API is not available for Cloud Datastore projects

我尝试通过运行以下CLI命令通过CLI添加Firestore:

gcloud services enable firestore.googleapis.com

上面的命令确实使Firestore出现在Google Cloud Platform Console上以及通过Google Cloud CLI启用的服务列表中,但实际上并不能解决我尝试与Firestore交互时遇到的错误。

有人知道使用Firebase / GCloud CLI或API启用Firestore for Firebase的方法吗?它可能只需要在控制台上单击两次,但会打断我正在建立的整个自动化过程。

0 个答案:

没有答案