本文說明如何刪除預訂。如要瞭解如何刪除未來預留項目要求,請參閱取消或刪除未來預留項目要求。
刪除預留項目,停止為不再需要的預留資源付費。
限制
刪除預訂單前,請考量下列事項:
您只能刪除建立共用保留項目的專案中的共用保留項目。
只有在沒有 Compute Engine 執行個體使用時,才能刪除明確指定的預留項目。如果有任何執行個體使用預留空間,請在刪除預留空間前,採取下列任一做法:
您只能在未來預留項目的預留期結束後,刪除自動建立的預留項目。
您必須先取代保留訂單,才能刪除與承諾合約連結的保留訂單。
事前準備
-
如果尚未設定,請先設定驗證機制。「驗證」是指驗證身分,以便存取 Google Cloud 服務和 API 的程序。如要從本機開發環境執行程式碼或範例,請選取下列任一選項,以便對 Compute Engine 進行驗證:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
- Set a default region and zone.
-
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
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
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
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
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
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
-
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
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
在 Google Cloud 控制台,前往「Reservations」(預留項目) 頁面。
在「On-demand reservations」分頁 (預設) 中,選取要刪除的預留項目。
按一下
「刪除」。按一下「Delete」(刪除) 確認操作。
RESERVATION_NAME
:保留項目的名稱。ZONE
:預留空間所在的區域。PROJECT_ID
:您建立預留容量的專案 ID。ZONE
:預留空間所在的區域。RESERVATION_NAME
:保留項目的名稱。- 瞭解如何查看預訂資訊。
Go
如要在本機開發環境中使用本頁面上的 Go 範例,請先安裝並初始化 gcloud CLI,然後使用您的使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
Java
如要在本機開發環境中使用本頁面上的 Java 範例,請先安裝並初始化 gcloud CLI,然後使用您的使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
Node.js
如要在本機開發環境中使用本頁面上的 Node.js 範例,請先安裝並初始化 gcloud CLI,然後使用您的使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
Python
如要在本機開發環境中使用本頁面上的 Python 範例,請先安裝並初始化 gcloud CLI,然後使用您的使用者憑證設定應用程式預設憑證。
詳情請參閱 Set up authentication for a local development environment。
REST
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
詳情請參閱 Google Cloud 驗證說明文件中的「驗證以使用 REST」。
必要的角色
如要取得刪除保留單所需的權限,請要求管理員授予您專案的 Compute Admin (
roles/compute.admin
) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。這個預先定義的角色包含
compute.reservations.delete
權限,這是刪除預訂項目所需的權限。刪除預留項目
如果您刪除任何相符運算執行個體可自動使用的保留項目,則任何使用已刪除保留項目的執行個體都會繼續執行。您仍須支付這些執行個體的費用。
您可以刪除單一或多筆預訂。如果有多個預留項目,請使用 Google Cloud 控制台。針對單一預訂,請選取下列任一選項:
主控台
gcloud
如要刪除保留項目,請使用
gcloud compute reservations delete
指令:gcloud compute reservations delete RESERVATION_NAME \ --zone=ZONE
更改下列內容:
Go
Java
Node.js
Python
REST
如要刪除預留項目,請對
reservation.delete
方法發出DELETE
要求:DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/reservations/RESERVATION_NAME
更改下列內容:
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-06-19 (世界標準時間)。
-