如何启用 Cloud Pub/Sub API 以在 App Engine 中使用它
How to enable Cloud Pub/Sub API to use it in App Engine
您想从您的 App Engine 应用程序发送和使用 Cloud Pub/Sub 消息。云 Pub/Sub API 当前已禁用。您将使用服务帐户向 API 验证您的应用程序。您希望确保您的应用程序可以使用 Cloud Pub/Sub。什么应该
你呢?
一个。在 GCP 控制台的 API 库中启用云 Pub/Sub API。
乙。依靠云Pub/Sub API Service Account 访问时的自动启用。
C。使用 Deployment Manager 部署您的应用程序。依靠正在部署的应用程序使用的所有 API 的自动启用。
D.授予 App Engine 默认服务帐户 Cloud Pub/Sub Admin 角色。让您的应用程序在首次连接到 Cloud Pub/Sub.
时启用 API
我意识到如果我构建一个使用 pubsub 的应用程序。它无需手动启用 pubsub api 即可工作。但我在文档中找不到任何相关内容。哪个是正确答案?
You want to send and consume Cloud Pub/Sub messages from your App
Engine application. The Cloud Pub/Sub API is currently disabled. You
will use a service account to authenticate your application to the
API. You want to make sure your application can use Cloud Pub/Sub.
What should you do?
让我们分析每个可能的答案以确定最佳答案。
A. Enable the Cloud Pub/Sub API in the API Library on the GCP Console.
这是一个可能的答案。标准方法是在 Google Cloud Console 中启用服务。您还可以使用 Cloud SDK CLI gcloud services enable pubsub.googleapis.com
启用服务
B. Rely on the automatic enablement of the Cloud Pub/Sub API when the
Service Account accesses it.
这不是一个可能的答案。 Google 当服务帐户访问它时,云服务不会自动启用。首先,服务帐户不访问 APIs。服务帐户用于获取 OAuth 访问令牌(或身份令牌)。这些令牌用于授权 APIs。 API 首次访问时不会自动启用服务。
C. Use Deployment Manager to deploy your application. Rely on the
automatic enablement of all APIs used by the application being
deployed.
这不是一个可能的答案。 Deployment Manager 不会自动启用服务。您可以使用 Deployment Manager 资源类型来启用服务。您必须为每个要启用的 API 创建一个虚拟资源。
D. Grant the App Engine Default service account the role of Cloud
Pub/Sub Admin. Have your application enable the API on the first
connection to Cloud Pub/Sub.
这不是一个可能的答案。云 Pub/Sub 管理员没有启用服务的权限。要启用服务,服务帐户(或用户帐户)将需要 roles/serviceusage.serviceUsageAdmin
或具有 serviceusage.services.enable
.
权限的其他角色
鼓点请....
因此我认为最佳答案是 A。
您想从您的 App Engine 应用程序发送和使用 Cloud Pub/Sub 消息。云 Pub/Sub API 当前已禁用。您将使用服务帐户向 API 验证您的应用程序。您希望确保您的应用程序可以使用 Cloud Pub/Sub。什么应该 你呢?
一个。在 GCP 控制台的 API 库中启用云 Pub/Sub API。
乙。依靠云Pub/Sub API Service Account 访问时的自动启用。
C。使用 Deployment Manager 部署您的应用程序。依靠正在部署的应用程序使用的所有 API 的自动启用。
D.授予 App Engine 默认服务帐户 Cloud Pub/Sub Admin 角色。让您的应用程序在首次连接到 Cloud Pub/Sub.
时启用 API我意识到如果我构建一个使用 pubsub 的应用程序。它无需手动启用 pubsub api 即可工作。但我在文档中找不到任何相关内容。哪个是正确答案?
You want to send and consume Cloud Pub/Sub messages from your App Engine application. The Cloud Pub/Sub API is currently disabled. You will use a service account to authenticate your application to the API. You want to make sure your application can use Cloud Pub/Sub. What should you do?
让我们分析每个可能的答案以确定最佳答案。
A. Enable the Cloud Pub/Sub API in the API Library on the GCP Console.
这是一个可能的答案。标准方法是在 Google Cloud Console 中启用服务。您还可以使用 Cloud SDK CLI gcloud services enable pubsub.googleapis.com
B. Rely on the automatic enablement of the Cloud Pub/Sub API when the Service Account accesses it.
这不是一个可能的答案。 Google 当服务帐户访问它时,云服务不会自动启用。首先,服务帐户不访问 APIs。服务帐户用于获取 OAuth 访问令牌(或身份令牌)。这些令牌用于授权 APIs。 API 首次访问时不会自动启用服务。
C. Use Deployment Manager to deploy your application. Rely on the automatic enablement of all APIs used by the application being deployed.
这不是一个可能的答案。 Deployment Manager 不会自动启用服务。您可以使用 Deployment Manager 资源类型来启用服务。您必须为每个要启用的 API 创建一个虚拟资源。
D. Grant the App Engine Default service account the role of Cloud Pub/Sub Admin. Have your application enable the API on the first connection to Cloud Pub/Sub.
这不是一个可能的答案。云 Pub/Sub 管理员没有启用服务的权限。要启用服务,服务帐户(或用户帐户)将需要 roles/serviceusage.serviceUsageAdmin
或具有 serviceusage.services.enable
.
鼓点请....
因此我认为最佳答案是 A。