如要將應用程式部署至 App Engine,您必須建立 Google Cloud 專案 和 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 專案
- 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自體驗產品的實際應用成效。新客戶還能獲得價值 $300 美元的免費抵免額,能用於執行、測試及部署工作負載。
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud Build API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud Build API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
執行下列
gcloud指令,啟用 App Engine 並建立相關聯的應用程式資源。請注意,選取位置後即無法變更。gcloud app create
- 由於新專案中服務帳戶的預設使用方式異動,以及預設安全機構政策異動,您可能需要將額外角色授予部署服務帳戶。如要進一步瞭解如何授予特定角色,請參閱疑難排解指南。
App Engine 位置
App Engine 具有區域性,這表示執行您應用程式的基礎架構位於特定區域,並由 Google 負責管理,實現該區域內所有可用區之間的備援可用性。
選擇應用程式執行所在區域時,主要考量因素是延遲時間、可用性或耐久性方面的需求。原則上可以選擇距離應用程式使用者最近的區域,但也應考慮 App Engine 的可用地區,以及應用程式所用其他Google Cloud 產品和服務的位置。如果跨多個位置使用服務,可能會影響應用程式的延遲時間和定價。
應用程式的地區設定完成後即無法更改。
如果您已建立 App Engine 應用程式,可以透過下列任一方式查看其區域:
請執行
gcloud app describe指令。在 控制台中開啟 App Engine 資訊主頁 Google Cloud 。 區域會顯示在頁面頂端附近。
後續步驟
Google Cloud 專案設定完成後,即可開始編寫基本網路服務。