正在設定環境

  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. 啟用 Cloud Run Admin API
  7. 安裝並初始化 gcloud CLI。
  8. 更新元件:
    gcloud components update
  9. 您可以選擇使用 gcloud 屬性設定平台和預設 Cloud Run 區域,避免指令列提示:
    gcloud config set run/region REGION
    將 REGION 替換為要使用的預設區域。
  10. (選用) 安裝 Docker,在本機建構 Docker 容器。您可以設定 Docker,使用 gcloud CLI 憑證輔助程式存取 Artifact Registry:
    gcloud auth configure-docker LOCATION-docker.pkg.dev
    將 LOCATION 替換為容器存放區的區域名稱,例如 us-west2。

Cloud Run 地區

Cloud Run 具有「地區性」,這表示執行 Cloud Run 服務的基礎架構位於特定地區,並且由 Google 代管,可為該地區內的所有區域提供備援功能。

選擇 Cloud Run 服務的執行地區時,請將延遲時間、可用性或耐用性需求做為主要考量。原則上可以選擇距離使用者最近的區域,但也應考慮 Cloud Run 服務所用其他 Google Cloud產品的位置。如果跨多個位置一起使用產品,可能會影響服務的延遲時間和成本。 Google Cloud

Cloud Run 可在下列地區使用:

採用級別 1 定價

採用級別 2 定價

如果您已建立 Cloud Run 服務,即可在 Google Cloud 控制台的 Cloud Run 資訊主頁中查看區域。

選用:使用 Cloud Code 工具開發新服務

您可以使用下列 Cloud Code 工具,而不必使用 Google Cloud 控制台或 Google Cloud CLI 建立新服務:

後續步驟

如要瞭解如何從程式碼來源建構容器、推送至 Artifact Registry,以及部署容器,請參閱下列資源: