项目的结算帐号未打开 GCP 要确认您的项目已启用结算功能,请按照以下步骤操作:要重新启用对项目的计费,请执行以下操作

问题描述

我正在尝试使用命令行将计算实例启动到 GCP:

gcloud compute instances create instance-1 --zone=uscentral1-a

它告诉我该项目的帐单尚未开放:

API [compute.googleapis.com] not enabled on project [847006780503].
Would you like to enable and retry (this will take a few minutes)?
(y/N)?  Y

Enabling service [compute.googleapis.com] on project [847006780503]...
ERROR: (gcloud.compute.instances.create) Failed_PRECONDITION: Billing account for project '847006780503' is not open. Billing must be enabled for activation of service(s) 'compute.googleapis.com,compute.googleapis.com,compute.googleapis.com' to proceed.
- '@type': type.googleapis.com/google.rpc.PreconditionFailure
  violations:
  - subject: ?error_code=390002&project=847006780503&services=compute.googleapis.com&services=compute.googleapis.com&services=compute.googleapis.com
    type: googleapis.com/billing-enabled
- '@type': type.googleapis.com/google.rpc.ErrorInfo
  domain: serviceusage.googleapis.com/billing-enabled
  Metadata:
    project: '847006780503'
    services: compute.googleapis.com,compute.googleapis.com
  reason: UREQ_PROJECT_BILLING_NOT_OPEN

我可以在控制台中启动计算实例,但不能在 CLI 中启动。

如何为我的项目启用计费,以便我可以使用 CLI 启动实例?

解决方法

要确认您的项目已启用结算功能,请按照以下步骤操作:

  1. 登录 Google Cloud Console
  2. 在 Google Cloud Console 页面顶部的项目下拉菜单(我的项目)中,选择您的项目。
  3. 打开控制台导航菜单 ,然后选择计费。

如果项目未启用计费,将显示一个弹出窗口,其文本类似于:

"This project is not linked to a billing account"

如果是这种情况,您可以按照以下文档对您的项目启用计费:Enable billing for an existing project

要重新启用对项目的计费,请执行以下操作。

  1. Sign in to the Manage billing accounts page 在 Google Cloud Console 中。

  2. 选择我的项目标签以查看项目列表以及每个项目的关联 Cloud Billing 帐号。

  3. 从项目列表中,找到您要为其重新启用计费的项目,然后点击旁边的菜单。

  4. 选择更改结算,然后选择所需的目标 Cloud Billing 帐号。