.NET 使用入门

本教程面向初次在云端构建应用(例如 工程师和 Web 开发者)的人员,他们希望了解适用于 的关键应用开发概念 Google Cloud。

目标

费用

在本文档中,您将使用 的以下可计费组件: Google Cloud

本文档中的说明旨在将您的资源使用量控制在 的 Google Cloud's 始终免费 层级的限制范围内。 您可使用 价格计算器 根据您的预计使用情况来估算费用。

新 Google Cloud 用户可能有资格申请免费试用

完成本文档中描述的任务后,您可以通过删除所创建的资源来避免继续计费。如需了解详情,请参阅清理

准备工作

  1. 登录您的 Google Cloud 账号。如果您是 Google Cloud的新用户, 请创建一个账号,以评估我们的产品在 实际场景中的表现。新客户还可以获得 300 美元的免费抵用金,用于 运行、测试和部署工作负载。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  5. Verify that billing is enabled for your Google Cloud project.

  6. 如需在原生模式下创建 Firestore 数据库,请完成以下步骤:
    1. 在 Google Cloud 控制台中,前往 Firestore 创建数据库 页面。

      前往 Firestore 创建数据库

    2. 选择一种 Cloud Firestore 模式 屏幕中,点击选择原生模式
    3. 选择 Firestore 数据库的 位置。此位置设置是您的 默认 Google Cloud 资源位置,用于您的 Google Cloud 项目 。 此位置将用于 Google Cloud 项目中 Google Cloud 需要设置位置的服务,特别是默认的 Cloud Storage 存储桶和您的 Cloud Run 应用。
    4. 点击创建数据库
  7. 启用 Cloud Run API、Cloud Storage JSON API、Cloud Logging API 和 Error Reporting API。

    启用 API 所需的角色

    如需启用 API,您需要拥有 serviceusage.services.enable 权限。如果您 创建了项目,则可能已通过 所有者角色 (roles/owner) 拥有此权限。否则,您可以通过 Service Usage Admin 角色 (roles/serviceusage.serviceUsageAdmin) 获得此权限。 了解如何授予角色

    启用 API

  8. 克隆示例代码库并在 Cloud Shell 中打开示例应用:
    前往 Cloud Shell

    利用 Cloud Shell,您可以直接在浏览器中通过命令行访问 Google Cloud 资源。

  9. 在克隆代码库的提示中,点击确认
  10. 在 Cloud Shell 中,配置 gcloud 工具以使用 新 Google Cloud 项目:

    # Configure gcloud for your project
    gcloud config set project PROJECT_ID