建立專案

您必須建立 Google Cloud 專案與 App Engine 應用程式資源,才能將應用程式部署至 App Engine。

Google Cloud 專案是頂層容器,存放您的 App Engine 應用程式及其他 Google Cloud 資源。

App Engine 應用程式是一種資源,您必須建立該資源才能啟用 App Engine。App Engine 應用程式資源可定義您想要執行網路服務並儲存其相關設定、憑證與中繼資料的所在地區。您只能為每個 Google Cloud 專案建立一個 App Engine 應用程式資源,且建立這些資源之後,就無法再變更指定地區。

如果您已經有啟用 App Engine 和 Cloud Build API 的專案,可以繼續撰寫您的網路服務。 Google Cloud

建立 Google Cloud 專案

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Cloud Build API.

    Enable the API

  5. Install the Google Cloud CLI.

  6. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  7. To initialize the gcloud CLI, run the following command:

    gcloud init
  8. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  9. Make sure that billing is enabled for your Google Cloud project.

  10. Enable the Cloud Build API.

    Enable the API

  11. Install the Google Cloud CLI.

  12. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  13. To initialize the gcloud CLI, run the following command:

    gcloud init
  14. 執行下列 gcloud 指令以啟用 App Engine 並建立關聯應用程式資源。請注意,您選取的位置一經設定即無法變更。
    gcloud app create
  15. 由於新專案中 Cloud Build 使用服務帳戶的預設行為有所變更,以及預設安全機構政策變更,您可能需要將額外角色授予部署服務帳戶。如要進一步瞭解如何授予特定角色,請參閱疑難排解指南
  16. App Engine 位置

    App Engine 具有「地區性」,這表示執行應用程式的基礎架構位於特定地區,且由 Google 代管,可為該地區內的所有區域提供備援功能。

    選擇應用程式的執行地區時,請將您在延遲時間、可用性和耐用性方面的要求,做為主要考量。一般來說,您可以選擇距離您應用程式使用者最近的地區,但您也應該考慮 App Engine 的可用位置,以及應用程式使用的其他Google Cloud 產品和服務的位置。如果跨多個位置使用服務,可能會影響應用程式的延遲時間和定價

    應用程式的地區設定完成後即無法更改。

    如果您已建立 App Engine 應用程式,可以透過下列方式查看其區域:

    • 請執行 gcloud app describe 指令。

    • 在 Google Cloud 控制台中開啟 App Engine 資訊主頁。區域會顯示在頁面頂端附近。

    後續步驟

    現在您已設定好 Google Cloud 專案,可以開始撰寫基本網路服務。