您必須建立 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 專案
- 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.
-
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
(
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.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
Install the Google Cloud CLI.
-
如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。
-
如要初始化 gcloud CLI,請執行下列指令:
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
(
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.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. -
Install the Google Cloud CLI.
-
如果您使用外部識別資訊提供者 (IdP),請先 使用聯合身分登入 gcloud CLI。
-
如要初始化 gcloud CLI,請執行下列指令:
gcloud init -
執行下列
gcloud指令以啟用 App Engine 並建立關聯應用程式資源。請注���,您選取的位置一經設定即無法變更。gcloud app create
- 由於新專案中 Cloud Build 使用服務帳戶的預設行為有所變更,以及預設安全機構政策異動,您可能需要將額外角色授予部署服務帳戶。如要進一步瞭解如何授予特定角色,請參閱疑難排解指南。
請執行
gcloud app describe指令。在 Google Cloud 控制台中開啟 App Engine 資訊主頁。區域會顯示在頁面頂端附近。
App Engine 位置
App Engine 具有「地區性」,這表示執行應用程式的基礎架構位於特定地區,且由 Google 代管,可為該地區內的所有區域提供備援功能。
選擇應用程式的執行地區時,請將您在延遲時間、可用性和耐用性方面的要求,做為主要考量。一般來說,您可以選擇距離您應用程式使用者最近的地區,但您也應該考量 App Engine 的適用地區,以及應用程式使用的其他Google Cloud 產品和服務的位置。如果跨多個位置使用服務,可能會影響應用程式的延遲時間和定價。
應用程式的地區設定完成後即無法更改。
如果您已建立 App Engine 應用程式,可以透過下列方式查看其區域:
後續步驟
現在您已設定好 Google Cloud 專案,可以開始撰寫基本網路服務。